Log in or register to post comments

400 Bad Request sometimes

August 19, 2013 - 10:37am #1

Hi all,

I am trying to upload target image via PostNewTarget.php sample codes. 

However, the uploads fail 80% of the time, works occasionally.  

I get this error: 

/targetsUnexpected HTTP status: 400 Bad Request


The request includes one line email address metadata, and 0.5 compressed iphone camera image. The image is uploaded through a 3rd-party server.

Do you think it has anything to do with the way I set up my HTTP request or purely a network connection problem?


Thanks in advance.


400 Bad Request sometimes

August 26, 2013 - 1:20pm #6

Glad to hear you managed to solve it (and happy it was caused by Vuforia :-)

Thanks for sharing the solution


400 Bad Request sometimes

August 26, 2013 - 10:06am #5

Hi all, 

I finally solved the problem. 

I am not sure if its going to help anyone, since it had nothing to do with Vuforia.

I set up my HTTP body by NSJSONSerialization dataWithJSONObject,  but I did not set its content type to application/json.  I guess php json_decode does not read well without the content-type explicitly specified. It is before sending a request to the TargetManager.

Anyway, thanks guys for the help. Really appreciate it.

400 Bad Request sometimes

August 20, 2013 - 1:09am #4

Hi Massanishi,

the fact that you see width = 0.0 instead of 320.0 is a known issue of the target Manager UI, which does not reflect the actual width of targets that have been updated throught the VWS API (but your target width is actually correctly set to 320, so, no need to worry about that; we are also working to fix the TM UI).


Concerning the failure message, the bad request error typically does not indicate a connection problem, but rather something wrong with your HTTP request, which may be cause by:

- the metadata (as David suggested), or:

- the image (maybe some of your images are too large ? consider that the max allowed size is 2.25 MB), or:

- something wrong with the way you setup your query.


Have you tried using the original PHP sample code (without any changes) and just uploading an image which is stored locally on your file system ? also, make sure the image is JPG or PNG, in RGB 24-bit format (no CMYK or RGBA), and that the size does not exceed 2.25 MB.

Also, the metadata size should not exceed 150KB.

See also:



400 Bad Request sometimes

August 19, 2013 - 12:30pm #3

Hi David,

The metadata has been same for all posts whether it is success or failure. 

Although I have not tested with the exact same image, it is the same kind of photos taken from iphone4 compressed in the exact same way. 

This is the full returned code.





Mon, 19 Aug 2013 19:20:28 GMT

/targetsUnexpected HTTP status: 400 Bad Request {"result_code":"Fail","transaction_id":"5656c4891e9d43469b6fa2d4022cba3a"}

Something I noitced is that even those successful ones show width = 0.0, when I open it in the targetManager. I am sure it has been set to 320.0 with PostNewTarget.php sample, but maybe it has some relation?

400 Bad Request sometimes

August 19, 2013 - 11:52am #2

Are you seeing intermittent failures even when using the same metadata content? - i.e. POSTs with the same email and image fail 80% of the time.

If the metadata for a successful POST is successful for all POSTs w/ that metadata, then it's like the metadata itself that is causing problems.

Also what is the JSON body of the response you are seeing?

Log in or register to post comments