Metadata of Amazon S3 object not getting updated while making PUT request on API using Postman - amazon-s3

I am following this documentation (https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-upload-image-s3/) to upload S3 object using API gateway, with no Lambda in between. This works using Postman! The object gets uploaded, but the user-defined metadata is not been reflected in the object.
I am trying to add user-defined metadata to headers, but that seems to be not working. I also tried to add "x-amz-meta-{key}": "{value}" in the form-data field of the body, and that did not work as well. Any recommended solution? Thanks in advance!

to Add metadata in PUT/POST request Created by API Gateway, you need to do the following:
Go to your API Method PUT/POST Method Request
Choose HTTP Request Headers then Add Header x-amz-meta-{YOUR-METADATA-NAME}
Go to your API Method PUT/POST Integration Request
Choose HTTP Headers then you will find your created Header in step 2 as Name (if not then create it) then in Mapped from Tab write
method.request.header.x-amz-meta-{YOUR-METADATA-NAME}
Deploy then send put request with header key as x-amz-meta-{YOUR-METADATA-NAME} and add your value then
visit s3 object you created then choose Edit Metadata then you find
the added metadata
to Get Metadata with GET request Created by API Gateway beside the object in response headers, you need to do the following:
Go to your API Method Response then unfold right Arrow located on the left of 200.
choose Add Header on Response Headers for 200 then Add x-amz-meta-{YOUR-METADATA-NAME}
Go to your API Method Integration Response
unfold Header Mappings then you will find Response Header you created in previous step (if not then create it) then Add integration.response.header.x-amz-meta-{YOUR-METADATA-NAME} in Mapping value tab
Deploy then test it using Postman then you find metadata in response headers
have a good luck.

Related

Postman request - how to get data from endpoint based on API documentation

I want to retrieve data from a data warehouse that has a web-based API, I need to use an API key for authentication and use the GET / Customers command to retrieve the list of customers data, but when I am using that same thing in postman, it's returning the same documentation page of the data warehouse?
I am new to this any help will be really appreciated.
The URL doesn't look valid:
You need a base URL, endpoint, http method, authentication scheme, and credential or a token etc.
I don't know details about your system and API, so let's see an example:
base url is https://stackoverflow.com; your current base url is localhost:4444, is your server running on your machine? If so, it might be correct, but I assumer you're talking about a server running somewhere else, not on your computer
endpoint (path parameter) is /questions/69883697, in your case /customers
http method is GET and you find it here in Postman; it also means it will not go into query parameters where you put it:
authentication scheme - your docs mentions an api key that goes into a header called Authorization, so you have to set it in Headers, not as a query parameter:
Read carefully what's on your screen, Postman uses the same language as your API documentation, so if your doc speaks about headers, you need to go into Headers tab in Postman.

Salesforce Commerce Cloud Ocapi

I am working on the open commerce api on SFCC, I found out something weird and wanted to know why.
When making a get request from the Shop api, the Bearer is not compulsory but on all other requests (patch, post, put, delete...) the Bearer is required.
Anyone knows why ?
The GET requests only fetches data without any modification to the data. All other request methods are usually used to modify data in the backend:
POST -> Create resource
PUT -> Update resource with replace
PATCH -> Partially update resource
DELETE -> remove resource
Also see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
For that reason you have to authenticate with the OCAPI if you are using one of these methods.

How do I create a mock server backend API with Postman?

I'm not understanding this tutorial.
I have a collection set up in Postman, I created a GET request in the collection and an example.
I'm not sure what to put in the request URL for the mock API example and what values to put in key/value in the request call.
Following the examples from the Postman documentation you mentioned - At Step 5 you should have a mock for the collection:
I've saved a simple GET request http://jsonplaceholder.typicode.com/users to the collection using the free jsonplaceholder API which will return details about users.
Once you have that response, hit the "Save Response" button and this will save that response as an example that can use with the mock server.
You can make requests against the mock server URL and add your route to the end of this in the Request Field. For me, it would look something like https://914aae16-28d5-47f1-8954-8a4d7b5e1daf.mock.pstmn.io/users

Use authentication token in follow-up requests in Postman

My app API requires authentication via an authentication token. In short, we send a request to a /authentication endpoint and it responds with a JSON object containing a token, like:
{"token": "xxxxxxxxxxxxxxxxxxxxxx"}
Every other API endpoint in our application requires an authentication header containing this token. Now, in Postman it's possible to do the authentication request, copy the token, open the next endpoint and paste the authentication header in manually. But this becomes tedious and time-consuming when testing lots of endpoints.
Is there a way to have Postman save and automatically add the authentication token from one request in any follow-up requests?
Even better, could Postman automatically send the /authentication request prior to any of the other requests?
Postman allows you a wide variety of options when crafting API requests.
In your case, You can create a global variable for your token when you receive it by:
var jsonData = JSON.parse(responseBody);
postman.setGlobalVariable('token', jsonData.token);
This would go in your Tests tab, in order to execute this script after your request has been completed.
Now, a global variable token is set and can be accessed using {{token}} syntax in the following API requests you make.
I'll demonstrate it to you regarding the same, with a similar example:
1. Save the data of latitude and longitude into the global variables lat and long.
2. Reuse the data by referring to the name of the variable, i.e. lat and long by enclosing them within curly braces like {{lat}} and {{long}}.
You can also manage these global variables, by clicking on the gear icon in the top right corner, and selecting manage environments then opening the Globals tab.
Tip: You can also, save the request to obtain the token into your collections, so that each time, you don't have to craft the URL to obtain the token.

Update issue fields in JIRA

Hi I am using postman client for Chrome to run my rest api calls. I am trying to update issue in JIRA via rest API. I have referred to JIRA API also for updating an issue.
I am using PUT method to update an issue fields. Here is the syntax.
PUT /rest/api/2/issue/{issueIdOrKey}
I am trying to update summary field like this.
{"update":{"summary":[{"set":"Bug in business logic"}]}}
But it is giving me the 400 bad request error.
and in the body its showing message "No content to map to Object due to end of input".
Please find the attached screenshot for more reference. Thanks in Advance.Jira Update issue
In postman rest API client, add the json object to Body as in the below picture.
I added authorization as Basic Authorization and provided JIRA credentials.
Note that the body should be raw and type should be JSON(application/json) instead of Text(default).
Response for this PUT request is 204 when update is successful.
Here is REST API Documentation for additional options.