Translate informatica Documentation into REST API Call (Postman) - postman

I am working on importing data into Informatica Reference360 and struggling to interpret documentation to construct an API call in POSTMAN.
Here is the example they are giving
POST https://use4-mdm.dm-us.informaticacloud.com/rdm-service/external/v1/import HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
IDS-SESSION-ID: XXXXXXXXXXXXXXXXXXXXXX
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=file; filename=import-code-values.csv
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=importSettings
Content-Type: application/json;charset=UTF-8
{
"delimiter":"COMMA",
"textQualifier":"DOUBLE_QUOTE",
"codepage":"UTF8",
"dateFormat":"ISO",
"containerType":"CODELIST",
"containerId":"9ab3201990a54dcdc86f54cf",
"startingRow":null
}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
The parts I do not understand:
what is this for: boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm.Should I put it in header as well?
What is this and where should I use it (are these two alternatives and only one should be used)?
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=file; filename=import-code-values.csv
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=importSettings
Content-Type: application/json;charset=UTF-8
...
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
How should I pass the actual file for import, should it be in body (form-data)?
If so which parts of the API payload should be in raw and which in form-data?
The link to documentation

Basically, your POST request requires 2 parts:
1.Upload file csv
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=file; filename=import-code-values.csv
2.Json object
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=importSettings
Content-Type: application/json;charset=UTF-8
You can check the similar question here:
How to upload a file and JSON data in Postman?

Answering my own questions:
what is this for: boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm.Should I put it in header as well?
this is generated automatically in the header by postman
What is this and where should I use it (are these two alternatives and only one should be used)?
both of them should
If so which parts of the API payload should be in raw and which in form-data?
everything should be input in body - form data

Related

Attachment sent via AWS SES not visible on iphone

Our service send email with attachment which is not visible on ios devices.
AWS team suggested to add double quotes around file name but when i try to add ", MimeBodyPart turning into escape character.
MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setDisposition(Part.ATTACHMENT);
messageBodyPart.setDataHandler(new DataHandler(Base64.getMimeDecoder()
.decode(attachment.getAttachment()), attachment.getContentType()));
messageBodyPart.setFileName("\""+ attachment.getName()+"\"");
From: donotreply#abc.com To: test#abc.com Message-ID:
<962944318.2.1571250351443#[10.200.78.179]> Subject: subject for test
MIME-Version: 1.0 Content-Type: multipart/related;
boundary="----=_Part_1_977674685.1571250351337"
------=_Part_1_977674685.1571250351337 Content-Type: multipart/alternative;
boundary="----=_Part_0_474488818.1571250351334"
------=_Part_0_474488818.1571250351334 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
Hi your email send is success
------=_Part_0_474488818.1571250351334--
------=_Part_1_977674685.1571250351337 Content-Type: application/pdf; name="\"myData.pdf\"" Content-Transfer-Encoding:
base64 Content-Disposition: attachment; filename="\"myData.pdf\""
ICAgICAgICAgDXhyZWYNNCAxMQ0wMDAwMDAwMDE2IDAwMDAwIG4NCjAwMDAwMDA2NjAgMDAwMDAg
------=_Part_1_977674685.1571250351337--
Found fix, issue was with respect to content-type. changing content-type to multipart/mixed resolved it.

Sending headers for every part in multipart request

I would like to send specific headers with every part in multipart request. Example below.
POST /api/my_resource
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryFVgKJdNNgzHnHwTz
[Fri Aug 02 10:25:23 CEST 2019]
------WebKitFormBoundaryFVgKJdNNgzHnHwTz
Content-Disposition: form-data; name="field"
My-Custom-Header: value
some data ...
------WebKitFormBoundaryFVgKJdNNgzHnHwTz
Content-Disposition: form-data; name="file"; filename="my_file.txt"
Content-Type: text/plain
My-Custom-Header: value
Lorem ipsum ...
How to do this using postman?
See https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 for the multipart/form-data specs - it does not allow for custom headers.

Restsharp vs Postman - content-type for a video

For testing one of our API endpoints, I need to upload a video. Our testing framework uses RestSharp.
The call works with Postman, which generates the following relevant headers and body:
Content-Type: multipart/form-data; boundary=--------------------------285414664033564173408812
Accept: */*
content-length: 1055942
----------------------------285414664033564173408812
Content-Disposition: form-data; name=""; filename="uservideo.mp4"
Content-Type: video/mp4
// binary data here
Now, when attempting the same using RestSharp, the request is constructed as follows but it fails:
Accept: application/json
Content-Type: multipart/form-data; boundary=-----------------------------28947758029299
Content-Length: 1055956
-------------------------------28947758029299
Content-Disposition: form-data; name="uservideoTest"; filename="uservideo.mp4"
Content-Type: application/octet-stream
// binary data here
The code used is as follows:
restRequest.AlwaysMultipartFormData = true;
restRequest.AddFile(request.FileName, request.FullPath);
Is it possible to have the RestSharp request constructed like the Postman request?
Found it, the answer is:
restRequest.AlwaysMultipartFormData = true;
restRequest.AddFile(request.FileName, request.FullPath, "video/mp4");

Facebook Graph API: How To Publish Text To Page, Including Image Attachment?

The documentation gives an example of how to upload an image, not via url, but as an attachment:
https://developers.facebook.com/docs/messenger-platform/reference/attachment-upload-api
curl -F "message={'attachment':{'type':'image', 'payload':{'is_reusable':true}}}" -F "filedata=#square.png;type=image/png" "https://graph.facebook.com/v2.12/1843037429354999/photos?access_token=<ACCESS_TOKEN>"
This leads to the following request:
POST https://graph.facebook.com/v2.12/<MY_PAGE_ID>/photos?access_token=<MY_ACCESS_TOKEN> HTTP/1.1
Host: graph.facebook.com
User-Agent: curl/7.52.1
Accept: */*
Content-Length: 2833
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------c71046aadf1a4e33
--------------------------c71046aadf1a4e33
Content-Disposition: form-data; name="message"
{'attachment':{'type':'image', 'payload':{'is_reusable':true}}}
--------------------------c71046aadf1a4e33
Content-Disposition: form-data; name="filedata"; filename="square.png"
Content-Type: image/png
<IMAGE_DATA>
--------------------------c71046aadf1a4e33--
However, this example does not work as advertised. The json object in the message parameter is literally posted as text in the post.
I'd like to be able to send along json post data that includes a 'message' and a 'access_token', so that I don't have to include the access token in the url.
How can I ensure that the type/image/payload json object is applied as a configuration, rather than used as the literal post message?
And how can I send along 'message' and 'access_token' in the postdata?
Found the solution.
This command...
curl -F "access_token=<MY_ACCESS_TOKEN>" -F "message=This is the message I wanna post." -F "filedata=#square.png;type=image/png" "https://graph.facebook.com/v2.12/<MY_PAGE_ID>/photos"
Gives this working request:
POST https://graph.facebook.com/v2.12/<MY_PAGE_ID>/photos HTTP/1.1
Host: graph.facebook.com
User-Agent: curl/7.52.1
Accept: */*
Content-Length: 3077
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------e94f377a15b0500f
--------------------------e94f377a15b0500f
Content-Disposition: form-data; name="access_token"
<MY_ACCESS_TOKEN>
--------------------------e94f377a15b0500f
Content-Disposition: form-data; name="message"
This is the message I wanna post.
--------------------------e94f377a15b0500f
Content-Disposition: form-data; name="filedata"; filename="square.png"
Content-Type: image/png
<IMAGE_DATA>
--------------------------e94f377a15b0500f--
All of a sudden it dawned on me. If the 'message' parameter posts a message, then why not simply put the message I want to post in there. Might as well include 'access_token' then, too. And it worked.
Instead of the deprecated 'message', you can also use 'caption' and it will also work.
Anyway, I can now attempt to reproduce this http request from C#. Glad I found this, because it saves me the effort from having to install the Facebook PHP SDK just to see how such a request should be formed.
(Why is there so little Facebook Graph API C# support, anyway?)
I still have no idea how to properly send along the attachment/type/image/payload json object from Facebook's documentation, though.
Oh, well.

Upload file to Drive and set file name

I want to upload a file to Google Drive and set its name as I understood I have to use uploadType=multipart
I am under c++ and using cURL lib.
How can I proceed?
You need to make a multipart request with metadata and media parts. Use curl_formadd and make sure your request looks like:
POST /upload/drive/v2/files?uploadType=multipart HTTP/1.1
Host: www.googleapis.com
Authorization: your_auth_token
Content-Type: multipart/related; boundary="boundary_tag"
--boundary_tag
Content-Type: application/json; charset=UTF-8
{
"title": "My title"
}
--boundary_tag
Content-Type: image/jpeg
data
--boundary_tag--