Form-data in API Connect - apiconnect

How do I get request form-data as a string in API Connect? I tried to get it in Gateway script by different ways, like apim.getvariable('request.body') or session.input.readAsBuffer, but everything was unsuccessful. I have two attachments in form-data and I would like to split it in my script.
At the moment I haven't found any documentation about processing form-data in IBM API Connect.

If you are using a POST QueryString you can decode the URI component in your Gateway script using:
var myQueryString = decodeURIComponent(apim.getvariable('request.body').item(0).toBuffer().toString())

Related

Amazon Connect API didn't response correctly in Postman

I am trying to test Amazon Connect Rest API in Postman. The API name is GetMetricData. In Postman, I have provided all the required information that is mentioned in the documentation. I have provided the JSON body, URL, and Header, although API is responding 200 OK status but in the response, it is throwing the following errors that you can see in the following screenshots.
I have set AWS signature with proper credentials such as access key and secret key
In the second error it is suggesting me to enable Javascript in the browser which is already enabled in my browser.
Can someone please help me here, I don't know where I am doing wrong. As I am totally new in this field, any help would be appreciated.
Thanks
You are submitting the POST request to the UI distribution endpoint for your Amazon Connect instance, not an API endpoint. You are getting HTML and javascript response body back from the UI distribution because this is meant to be consumed by a browser.
Your API request should be sent to a URL that looks like https://connect.us-west-2.amazonaws.com/metrics/historical/<instanceId>. In this example, my Amazon Connect instance is located in the us-west-2 region so I'm using the connect.us-west-2.amazonaws.com endpoint. You can find all available Amazon Connect API endpoints in the documentation here

Azure logic app API http response with excel file download using Postman

Created azure logic app HTTP request it gives response for normal JSON schema However, I want to attach SharePoint excel sheet when I trigger the request from Postman.
1.How to used content type or schema to download the attached file. when postman request sent.
2.is that possible to download when you hit API through logic app
3.Generated HTTP POST URL is working
For your requirement, I test it in my side. It seems we do not need to set any value for "Content-Type" in headers of response. Please refer to my logic app below:
Then when you request the logic app url in postman, please choose "Send and Download" instead of "Send".
After that, you can download the file when request the url in postman.

Getting Unsupported Media Type in Postman response while sending GraphQL API mock request data

I am working on an application with graphQL and spring boot framework. Here I am using GraphQL's Schema-first approach to write my schema details. In my scenario, I need to update the user profile image using GraphQL. I am using my test client as postman and I have attached the mock request structure as well. When I send my mock data to the server, I am receiving '415 - Unsupported Media Type' error response. Can someone please guide me on this. ?
Also, please suggest if I have to use multipart file to get the uploaded file at the server.
Thanks in advance.

Why api response body is not showing in postman app generated documentation?

I am testing apis usng postman continuously and then generating api documentation using postman app.
But problem is that documentation is not displaying api response which i am receiving in postman console. Here is the response which i am receiving for most of my apis
How can i get response body also in my api documentation?
If the request has been saved to a collection, You can use the Save as example feature, found to the top right of the response body. This will open the example builder and once saved, this response body will be shown against the request on your API documentation.
More details of how that works can be found here:
https://learning.getpostman.com/docs/postman/collections/examples/#how-your-examples-appear-in-postman-documentation

Couldn't call aws api gateway from postman

I have created an api in amazon api gateway service with s3 proxy, and created a method post to upload a file to s3 using the document. Deployed the API and then using that url i tried to call the api from postman. But i couldn't post the file and it returns an error 'missing authentication token'.
I set authorization as NONE.
Then it returns an Unexpected "<" error.
Ah, okay. S3 only supports POST from an HTML form, which is why you see the error where it is expecting multipart formdata.
The method you need to use is PUT, instead of POST. PUT requires an item path, so you'll need to change the resource path to have a bucket and key, or get those from other places.
I have some more info on how to set this up in upload binary from api gateway to S3 bucket
It sounds like the document you're uploading isn't JSON. By default, API Gateway expects UTF-8 encoded JSON.
What content type are you sending with your Postman request?