2

I have got the following cURL command that is running expectedly:

curl -X POST
                        -H "Content-Type: application/json"
                        -d '{"duplicateEntitiesIds": [21,31,41]}'
                       {URL}:3003/v1/entities/5/merge

And I am trying to replicate that with Guzzle, which however fails, returning a 400 status code:

 $request   = $httpClient->post('{URL}:3003/v1/entities/'.$mainEntityId.'/merge',
                                       ['json' =>
                                                 ['duplicateEntitiesIds' => $duplEntitiesIdsToArray]
                                       ]
                                      );
 $response   = $request->send();

I have tried to change my post body , but it keeps failing. Any ideas would be appreciated.

NOTE

The data should be sent in the following format:

{"duplicateEntitiesId": [2,3,4]}
thitami
  • 828
  • 2
  • 21
  • 44
  • 1
    What do var dumps for `$mainEntityId` and `$duplEntitiesIdsToArray` look like? – Mike Brant Oct 13 '14 at 16:03
  • did you try hardcoded {"duplicateEntitiesId": [2,3,4]} ? if it works you know that $duplEntitiesIdsToArray have wrong values – zod Oct 13 '14 at 16:08
  • @MikeBrant mainEntityId is the expecting one, and $duplEntitiesIdsToArray is ["2616"] (the correct id) . – thitami Oct 13 '14 at 16:14
  • Is it string `"2616"` in the array? It looks like in your cURL example, you have an array of integers. – Mike Brant Oct 13 '14 at 16:15
  • @MikeBrant Yes, it is string. Should be something obvious that I am missing. – thitami Oct 13 '14 at 16:19
  • @zod I have entered this, but still no luck: ['body' => '{"duplicateEntitiesIds": [2,3,4]}' – thitami Oct 13 '14 at 16:27
  • did you try any http client app and test it ? try this .. may be you get specific error...not sure http://stackoverflow.com/questions/25040436/guzzle-handle-400-bad-request – zod Oct 13 '14 at 16:36
  • @zod Yes, I am using Guzzle. – thitami Oct 13 '14 at 16:37

0 Answers0