function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PRABHAKARAN V 5PRABHAKARAN V 5 

I am trying to send JSON data and File data from the content version to REST callout using the content type "Multipart/form-data" with boundary in the APEX class. But, I am getting "Bad-Request" as the response Status and "400" as the response code. If I

Hi,

I am trying to send JSON data and File data from the content version to REST callout using the content type "Multipart/form-data" with boundary in the APEX class. But, I am getting "Bad-Request" as the response Status and "400" as the response code.

If I send the same JSON data and file data to the REST callout using the "POSTMAN " tool, I receive a successful response.

Is there any other way to send JSON and file data in REST callout or any other body format needed for multipart/ form-data content type?

example of my body format:

------Boundary
Content-Disposition: form-data; name="jsondata"
Content-Type: application/json

{"id":"123","name":"test"}
-----Boundary
Content-Disposition: form-data; name="file"; filename="test.pdf"
Content-Type: application/pdf

file data
-----Boundary

regards,
prabhakaran
SwethaSwetha (Salesforce Developers) 
HI Prabhakaran,
Can you also include your apex code. Recommend reviewing this similar post from past

https://salesforce.stackexchange.com/questions/179814/salesforce-apex-posting-multipart-form-data-content-type
PRABHAKARAN V 5PRABHAKARAN V 5
Hi,       Thanks for your kind attention to my question. My issue got resolved, I made mistake in line breaking(\r\n) for the multipart form data body format. I have changed that mistake and got my response successfully. Thanks, Prabhakaran
SwethaSwetha (Salesforce Developers) 
Thanks for sharing the fix that worked for you. Hope it helps others facing the same issue in the future.
Ashutosh SinghAshutosh Singh
Hi Prabhakara, I've same situation. Can you help me out here by providing the request body logic.