Forum Discussion

DEOKAS's avatar
DEOKAS
New Member
4 years ago

Unable to set content type to application/json for a 'metadata' key in a multipart/form-data request

I have a multi-part POST request with two parts, a file and json metadata. I am able to  add "file" part and set the content-type through the attachment, but I am not able to set the content-type of the "json" 'metadata' part to "application/json".

2 Replies

  • richie's avatar
    richie
    Community Hero
    Hey DEOKAS,

    Im unsure i can help as ive never had a multipart REQUEST before....ive only had to deal with multipart RESPONSES.
    However if you explain more people might be able to help.
    Once you add the file, what is the type set as?
    Have you already set the type as multipart before you attach the file?
    You can only have one 'type' set in a single request as far as i was aware, so can you provide the http headers of a multipart POST request with a json file attachment and embedded json payload? Your technical requirements should define the requests http headers and i doubt youd have multiple Content-type headers in a request, so i dont think you actually need to set the type application/json....perhaps you have the application/json set after the multipart portion of the type (either comma or semi colon separated which ive seen on responses).

    Essentially we need to know thr http headers of a successful request and work backwards to define what you need....hence the reason im suggesting checking your functional requirements.

    Nice one,

    Rich
    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Thank you Richie!

       

      DEOKAS were you able to solve this? If not, please share more details with us that Richie is asking for๐Ÿ™‚