question

treasure_seekers avatar image
0 Likes"
treasure_seekers asked

The UploadImage example in the Java SDK apicallsdemo doesn’t work. Returns premature end of file because there is no response from server.

Upload Image example in Java SDK samples doesnt work. Returns premature end od file error because there is no response from server. Cant find a working example of Binary upload of site hosted image in Java.
uploadsitehostedpicturejdk
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

treasure_seekers avatar image
0 Likes"
treasure_seekers answered
Update: Works in Production... not in Sandbox. Any idea when it will be working in sandbox?
· 1
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

When I looked at the response content, I found that there is an HTTP 302 being returned with an empty response content. The redirect points to http://pages.sandbox.ebay.com/messages/page_not_responding.html, which itself, then returns an HTTP 302 redirecting to http://pages.sandbox.ebay.com/. I have actually seen the same "Premature End Of File" error in production pccassionally, but wasn't able to intercept the response headers. It looks like the eBay Java SDK is simply not designed to deal with the HTTP 302, and instead simply tries to parse the response content as XML, hence the error.
0 Likes 0 ·
edinburghsoftwareltd avatar image
0 Likes"
edinburghsoftwareltd answered
Looking into it a little further, it looks like it's the eBay SDK is sending up a Content-Type header with a comma instead of a semi-colon. Replacing the comma with a semi-colon, I no longer have this problem.
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

swappart avatar image
0 Likes"
swappart answered
I'm having this problem too. Where did you change the comma to a semicolon?
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

edinburghsoftwareltd avatar image
0 Likes"
edinburghsoftwareltd answered
@swappart - I changed this in com.ebay.sdk.pictureservice.eps.eBayPictureServiceXMLCall#setConnectionProperty()
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

swappart avatar image
0 Likes"
swappart answered
That solved my problem. Strange how it just now affected my application on the production site. It's been over a year since I could upload to the sandbox, but that works now too. Thank you.
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

edinburghsoftwareltd avatar image
0 Likes"
edinburghsoftwareltd answered
@swappart - No problem. I can only assume eBay are rolling out some stricter validation of request headers across their production servers. From [this][1] stackoverflow post, it sounds like the comma is not considered valid these days. Perhaps this was rolled out to the sandbox some time ago, and is only just making it to the production servers. Given the fact that it happens for me intermittently, I can only presume the rollout is gradual. [1]: https://stackoverflow.com/questions/35761248/which-separator-should-be-used-in-the-content-type-header-for-a-multipart-data-r
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

swappart avatar image
0 Likes"
swappart answered
I noticed I was getting a lot of failures last week. My workaround was to wrap the call in a while loop and break on success, log error on failure. At that time, it was never failing twice in a row. Maybe as you said, they implemented stricter validation, but it hadn't propagated to all their servers yet.
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.