Start a new topic

TargetApi randomly fails with 400

TargetApi randomly fails with 400


Hi, 

I'm currently testing a NodeJS solution where I first upload one image to Amazon S3, then pass on the S3 url to the TargetApi. I'm using the trial version. It may work for many consecutive calls then suddenly it fails and I get 400 error back. 

First I thought it was a timing issue with the S3, but I have tried resending, adding delays etc and seems not be related. Do you have any trouble shooting tips? 

Also, can I call TargetAPI with api-version 5 or only v3? 

Jens

Hi Jens,

Thanks for contacting us!

Usually a 400 response contains also a JSON body which gives more details about the problem. Is there any chance you can provide that body message ? It will help us in finding any issue.

As per your request: "Also, can I call TargetAPI with api-version 5 or only v3? "

You can use version 3 of the endpoint: the generated wtc will be compatible also with SDK 5.

Best Regards,

Simone

Thanks Simone, yes I have added logging of the body, the TargetAPI reports the image to be invalid for some reason.

So to be sure, I download the file using the very same url (just after upload to S3, but before passing on the S3 url to the TargetApi). The file does not seem to be corrupt, at least it opens up with paint.net.

I download the file again but from the S3 console, just after the 400 error, the file is still fine. (The S3 link expires after 15min by default I think)

 

BODY: {"code":400,"reason":"CORRUPT_IMAGE_TARGET","message":"Unfortunately one (or more) of your images seem to be invalid. Please check your request again. If the problem persist then contact us at support@wikitude.com","more                       Info":"http://www.wikitude.com/developer/documentation"}

 

Is it a timing issue after all?

Hi Jens,

It might be a timeout issue. I'm wondering if the S3 link is expiring before 15m. Can you increase the LifeCycle property for that bucket ?

S.

 

Hi Jens,

You found the point: query parameters of your URL seems to provoke some issue. 

The system tries to extract the targetName from the url and uses it as target id in the wtc file. For your URL the file is downloaded from our system with the name "POCgfb7flwt4fHJWzpzFo4k=". Consequently, the system refuses to process the file.

If you cannot provide any better URL then I would suggest to have a look at our Cloud Recognition API (here) You will find a more consistent way to manage your targets and generate wtc files.

Best,

Simone

I'm using the s3.getSignedUrl to get a public url. This function returns an url like this : https://abc-f19b4894-99c2-434c-9135-995a9907ef9f.s3.amazonaws.com/surfer.jpeg?AWSAccessKeyId=AKIAI2PGLHSL43L3BHJA&Expires=1450801852&Signature=Rfh%2FPOCgfb7flwt4fHJWzpzFo4k%3D

The above link should be valid 1 week from now, but was reported to be an invalid file. Is the format of the url causing the problem?

Edit : I forgot to mention that the problem could be reproduced with the Javascript Target Api sample (wikitude-targets-api-samples-masterJavaScript\run\TargetsAPITest.html)

var images = ;

Thanks Simone, 

yes the work-around was to make the url public, then the query parameters can be left out. 

Jens
Login or Signup to post a comment