Can you help me recreating this curl command into Rest callout...?
curl --request POST \
--url https://api.imgur.com/3/image \
--header 'authorization: Client-ID {{clientId}}' \
--header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
--form image=R0lGODlhAQABAIAAAAAAAP/
What I have written so far...
String apiUrl = 'https://api.imgur.com/3/image';
String apiKey = 'f714837c34e1426';
String boundary = '----WebKitFormBoundary7MA4YWxkTrZu0gW';
HttpRequest req = new HttpRequest();
Http http = new Http();
req.setMethod('POST');
req.setEndpoint(url);
Blob bodyValue = file;
String authorizationHeader = 'Client-ID ' + apiKey;
req.setHeader('Content-Type', 'multipart/form-data; boundary=' + boundary);
req.setHeader('Authorization', authorizationHeader);
req.setBodyAsBlob(bodyValue);
HTTPResponse res = http.send(req);
system.debug(res.getBody());
return res.getBody();
I am bit confused on How to use the boundary and add the form data as
image=R0lGODlhAQABAIAAAAAAAP
P.S. I did refer other posts that are similar to this...But they were bit confusing and didn't get me anywhere.
Thanks....