Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having Issues while using Unirest Libraries to attach Image in Rest Message #118

Open
sagarMinhas opened this issue Feb 27, 2018 · 0 comments

Comments

@sagarMinhas
Copy link

Hi Team,

I am using Unirest libraries to create Rest based message in Eclipse using java language. The code I have used is below (got from PostMan):

HttpResponse response = Unirest.post("XXXXXX")
.header("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
.header("Authorization", "Bearer XXXXXX")
.header("Cache-Control", "no-cache")
.body("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name="stringPart"\r\n\r\n{"AAAA":[{"BBBB":"passphrase","fileName": "check.wav", "bioType":60, "captureSequence":"CCCC"}] }\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name="check.wav"; filename="Sagar.jpeg"\r\nContent-Type: image/jpeg\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--")
.asString();

WebService is expecting a file attachment in the Rest message but I am getting below error from web service :

Response is {"id":null,"code":"error.invalid.file.format","errors":["File is claiming to be content-type: image/jpeg but is not properly formatted."],"args":["image/jpeg"]}

Can you please help on how to properly attach image in Rest Message. Above mentioned Rest message works fine in PostMan but it is not working when I am using it from Eclipse.

Thanks in Advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant