Great Headless API Useless

Hey folks!

I am trying to get up the basic API endpoint 

GET http:///store-api/v1/context

I set up a GET Request with the URL in Postman and added as header the sw-access-key. But I always get „Not Found“. How the hell is it possible? Or is the great headless sh*t from shopware, e.g. I want to query a description for a product only accessible via a plugin and hence useless for a PWA?

Here my simple config in Postman for the GET request:

I tried now nearly 200 calls. Nothing works.

Sometimes I get: {“errors”:[{“status”:“412”,“code”:“FRAMEWORK__ROUTING_SALES_CHANNEL_NOT_FOUND”,“title”:“Precondition Failed”,“detail”:“No matching sales channel found.”,“meta”:{“parameters”:}}]} when I try this URL:

http://…/sales-channel-api/v1/product

But I would be happy if I can get up running the context call to get all the sales channels, bcz the documentation says this:

Maybe someone noticed that the JSON here is not valid. Or am I missing something here?

I never was that frustrated with using a new tool.

1 „Gefällt mir“

Have you added the domain in the Administration? Shopware needs to know the domain you are calling, otherwhise it will deny your request. Just open the Headless sales channel in the Administration and add the domain you are calling.

 

After that start using the Store-API (6.2 only): https://docs.shopware.com/en/shopware-platform-dev-en/store-api-guide/sales-channel?category=shopware-platform-dev-en/store-api-guide#get-current-context

 

or the Storefront api (6.0.0 and newer)

https://docs.shopware.com/en/shopware-platform-dev-en/sales-channel-api/sales-channel-context-api?category=shopware-platform-dev-en/sales-channel-api

 

 

 

Thanks for the answer. Where can I add the Domain? In the main sales channel I can add the domain and there everything is listed. the headless does not have any of this „Domain“ List.

The Headless Channel only has: General Settings, API Access and Status section in the config of the channel itself. And in the Main channel I also have “Domains” but NOT in the headless

Which version do you use? Ist depends in it.

In general, You can add it to the Storefront as well, every storefront has both api endpoints too. The error above indicates that the domain is unkown to shopware.

In 6.2 you can add a domain to headless sales channels too.

 

You need a valid sw-access-key

I am using 6.1.5

I have one Storefront Channela and one Headless.

The sw-access-key is copied directly from the backend. I tried the sw-access-key from the storefront and the headless sales channel. Both dont work.

In my Case its „http://de.shopwaretest.de/sales-channel-api/v1/context“ and i copied the sw-access-key from the storefront-sales-channel. 

 

You will get „Not Found“ when requesting the Store-API in a version older than 6.2.0, so make sure you are using the right shopware-version. sales-channel-api should work in both versions (6.1.0 and 6.2.0). „FRAMEWORK__ROUTING_SALES_CHANNEL_NOT_FOUND“ is an indicator, that the domain is not known to shopware.

Ok thanks. With the sales channel API it works. I removed now the headless channel because that ones seems senseless. But the problem is still there: How to get the store-api working via this call: 

GET http://…/store-api/v1/context

Source: https://docs.shopware.com/en/shopware-platform-dev-en/store-api-guide/authentication?category=shopware-platform-dev-en/store-api-guide

So I will use the API from the storefront. Why do we have then a headless sales channel? Whats the sense of that? Also the channel api is the only one I can access. the others are not working.

@edinhobl schrieb:

So I will use the API from the storefront. Why do we have then a headless sales channel? Whats the sense of that? Also the channel api is the only one I can access. the others are not working.

As I said multiple times before - the store API is only available in the newest version (Release Candidate), It seems that you are using 6.1.x and therefore the headless channel has not domain setup and the store-api is not aivailable.

 

Use 6.2 not 6.1.5 as written before.

I do not recomment to delete one of the default saleschannels. Just dont use rhem if you do not need them.

All Apis are working with correct config and handling.

Ok thanks. I will check how I proceeed with that and if I can setup a custom PWA based on that. I am not sure currently.