This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal. |
Hi,
I want to ask about send file and json data with same request with multipart/formdata.
My code is like below
var httpclient = new kony.net.HttpRequest(); httpclient.open(constants.HTTP_METHOD_POST, "www.xyz", true ); httpclient.setRequestHeader("Content-type","multipart/formdata"); httpclient.setRequestHeader("Authorization","*******"); var frmData = new kony.net.FormData(); frmData.append("file", fileUpload); frmData.append("id", id); frmData.append("key", key); httpclient.send(frmData); httpclient.onReadyStateChange=callback;
fileUpload is rawBytes. id and key is string.
It give response "Invalid Key". But when I test on postman it has no problem.
Maybe my code is wrong,. Can senior Kony help me?
Thank you 😊
@Twvcey Rvndvll​ can you please help here. Thanks!
Hi Mr. @Tim Gwvhvm​
Thank you but the document on you shared only support for 1 by 1, not on same request..
On my case I need to upload file and upload the key (String type) too.
Thanks
frmData.append(f1.name, f1.read());
// sending rawbytes along with file name.
Did you try adding the key in place of file name???
Hi @Tim Gwvhvm​
I mean I want to upload file and key string
On my code like on snippet below
frmData.append("file", fileUpload); // "file" is key name parameter, the value is fileUpload (rawbytes)
frmData.append("key", key); // "key" is key name parameter, the value is key (string)
But when I try to test, it always give response "Invalid Key".
When I tried on postman like image below, it works . There is no issue.
**Image removed for security reasons**
is there no solution for this problem?
Can you try after removing
httpclient.setRequestHeader("Content-type","multipart/formdata");

Hi @Tim Gwvhvm​ ,
Still not worked.. It give response Invalid Key..