Salesforce Commerce Cloud Ocapi - api

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.

Related

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

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.

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.

GraphQL and Strapi Session

First of all the project is amazing, I had GraphQL working with MongoDB very quickly. Even GraphiQL with the ModHeader extension. However, I am trying to add policies to the graphQL endpoints and I am finding that ctx.session is always empty, even tho I am making authorized requests (via the Bearer token)
How does session work in this example? Do I need to query for the user every single time I create a request?
The user info is available through the ctx.state.user object and not the ctx.session. Also, feel free to take a look at the GraphQL example https://github.com/strapi/strapi-examples/tree/master/react-apollo

Implementing OAuth2 with Socrata API

I'm implementing the Socrata API to be able to parse publicly-available data from the City of Chicago open data set. I am really just concerned about the data itself, so I did not initially think that I would need to implement OAuth2 through an app exposed via ngrok to be able to GET the data.
My initial attempt was to take the GET requests mentioned in their documentation and try to get responses through Postman.
Here's an example of such an attempt:
I also added my Socrata App Token as a param in the querystring, but the same message was shown.
So I tell myself, ok, maybe they deprecated GET requests without making the client go through OAuth2. If they didn't deprecate these GET requests, I would prefer not to have to deal with OAuth2, but I began implementing the authentication process and everything went successfully until I got to the following instructions found here:
I have every single value that needs to be included in that POST request except for 'authorization_type'. Where does this come from? I tried leaving 'authorization_type' in as a string, but received a response similar to the 'Invalid username or password' message in the top image in this question.
Are you only accessing public datasets from Chicago's data portal? From your screenshot it looks like you're trying to access the Building Permits dataset, which is public.
Authentication is only required for modifying datasets or accessing private data, so chances are very good you don't even need to authenticate. Just include an application token with your request for throttling purposes.
Glad to help you figure out your OAuth workflow, but it sounds like it might be unnecessary.

To integrate with Silverpop

Can anyone guide how to integrate with Silverpop, using OAuth(tokens)?
I referred this link
connecting to web api using c#
and I was able to get access token. After this I don't know how to proceed.
Thanks.
Take a look at my github repo:
https://github.com/marcelluseasley/IBM-Marketing-Cloud-XML-API-Wrapper
It isn't finished, but I started working on an XML API wrapper for the Silverpop API. First of all, if you are trying to integrate with the API, you should be able to contact client support and get a copy of the API PDF.
In any case, you should have a client id, client secret, and refresh token. You will need these three things along with a header value of "refresh_token" for the "grant_type" header key.
So you will first sent a post to https://api(pod number).silverpop.com/oauth/token . This will return an access token in a json dictionary ("access_token").
Any subsequent calls made to the API endpoint (https://api(pod number).silverpop.com/XMLAPI will require that you pass this access token in the header section of your request:
"Authorization:" would be the header key and
"Bearer: (access token)" would be the header value
Looking at my code will make it clearer if you are using Python. Your best bet is to get a copy of the API documentation. You have to be a Silverpop client to get a copy though.
Good luck.
Check the follwing:
http://www.codeproject.com/Articles/758362/SilverPop-Integration
Follow the step by step guide.