[Progress Communities] [Progress OpenEdge ABL] Forum Post: Send an attachment file with a POST request

  • Thread starter Thread starter jpatel7
  • Start date Start date
Status
Not open for further replies.
J

jpatel7

Guest
I have a JSON object which I am sending in a POST request. It was working fine. But, now I need to send a text file as an attachment as well. I tried the following code: lv-multiPartEntity = new MultipartEntity(). lv-messagePart = new MessagePart("application/json", lv-requestParameters). lv-messagePart:Headers:Put( HttpHeaderBuilder:Build( "Content-Disposition") :Value("form-data; name=" + quoter("dataRequest")) :Header). /* ------------- I added this section ---------- */ lv-messagePart:Headers:Put( HttpHeaderBuilder:Build( "Content-Disposition") :Value('attachment; filename="C:\Users\me\Desktop\test.txt"') :Header). /* ---------------------------------------------- */ lv-multiPartEntity:AddPart(lv-messagePart). lv-request = RequestBuilder :POST(lv-webServiceURL, lv-multiPartEntity) :AddHeader("Accept", "application/json") :AddHeader("Authorization", "Bearer " + lv-accessToken) :ContentType("multipart/form-data") :Request. I also tried to add this file as a different messagePart, but it didn't work. What am I missing? Thanks in advance.

Continue reading...
 
Status
Not open for further replies.
Back
Top