Kong / Kong/unirest-nodejs

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

Open
#118 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
953
Forks
164
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Java multipart request shown in the issue and compare its body with the working Postman request. Check whether the image bytes are present and whether the multipart boundary and content type match; done means the service accepts the uploaded image as a valid file.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.