0

I wanted to upload a csv file in my salesforce instance via golang request from my server, now in salesforce's documentation, they gives an example like

curl https://yourInstance.salesforce.com/services/data/v23.0/sobjects/Document/ -H "Authorization: Bearer token" -H "Content-Type: multipart/form-data; boundary=\"boundary_string\"" --data-binary @newdocument.json

and

--boundary_string
Content-Disposition: form-data; name="entity_document";
Content-Type: application/json

{
   "Description" : "Marketing brochure for Q1 2011",
   "Keywords" : "marketing,sales,update",
   "FolderId" : "005D0000001GiU7",
   "Name" : "Marketing Brochure Q1",
   "Type" : "pdf"
}

--boundary_string
Content-Type: application/pdf
Content-Disposition: form-data; name="Body"; filename="2011Q1MktgBrochure.pdf"

Binary data goes here.

--boundary_string--

So how can I convert this request in golang?

kostix
  • 43,267
  • 10
  • 69
  • 137
0xTanvir
  • 31
  • 4
  • Use https://godoc.org/mime/multipart to create a multipart/form-data body. – Cerise Limón Oct 02 '18 at 11:37
  • 2
    Possible duplicate of [golang POST data using the Content-Type multipart/form-data](https://stackoverflow.com/questions/20205796/golang-post-data-using-the-content-type-multipart-form-data) – Steffen Ullrich Oct 02 '18 at 11:42

0 Answers0