# Wie aktiviere ich den Zugriff auf die Shopware 6 API? (Self-Hosted) No route found Error

**URL:** https://forum.shopware.com/t/wie-aktiviere-ich-den-zugriff-auf-die-shopware-6-api-self-hosted-no-route-found-error/71346
**Category:** Programmierung
**Created:** [3. Dezember 2020 um 12:20 UTC](https://forum.shopware.com/t/wie-aktiviere-ich-den-zugriff-auf-die-shopware-6-api-self-hosted-no-route-found-error/71346 "2020-12-03T12:20:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nbcoding](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@nbcoding](https://forum.shopware.com/u/nbcoding)
#### Post date: [3. Dezember 2020 um 12:20 UTC](https://forum.shopware.com/t/wie-aktiviere-ich-den-zugriff-auf-die-shopware-6-api-self-hosted-no-route-found-error/71346/1 "2020-12-03T12:20:51Z")

</div>

Hallo zusammen, ich muss für einen Kunden eine Schnittstelle einbinden. Diese soll natürlich über die Shopware 6 API laufen.

Wenn ich nun allerdings die URL [https://mein-shop.de/api/](https://mein-shop.de/api/) aufrufe bekomme ich folgende Fehlermeldung:

```
 {"errors":[{"code":"0","status":"404","title":"Not Found","detail":"No route found for \u0022GET \/api\/\u0022","meta":....}

```

Weiss jemand woran das liegen kann? In der .env Datei ist der Modus „dev“ eingetragen.

Mit freundlichen Grüßen&nbsp;

&nbsp;

---

<div class="post-metadata">

### Author: ![ThomasChr](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/thomaschr/32/10466_2.png) [@ThomasChr](https://forum.shopware.com/u/ThomasChr)
#### Post date: [3. Dezember 2020 um 12:24 UTC](https://forum.shopware.com/t/wie-aktiviere-ich-den-zugriff-auf-die-shopware-6-api-self-hosted-no-route-found-error/71346/2 "2020-12-03T12:24:48Z")

</div>

Afaik musst du da garnix aktivieren. Die Api ist immer da.

Anmelden kannst du dich z.B. mit dem User.

Probier doch mal den Link, da sollte dann denied kommen: [https://www.mein-shop.de/api/v3/product](https://www.mein-shop.de/api/v3/product)

---

<div class="post-metadata">

### Author: ![nbcoding](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@nbcoding](https://forum.shopware.com/u/nbcoding)
#### Post date: [3. Dezember 2020 um 12:28 UTC](https://forum.shopware.com/t/wie-aktiviere-ich-den-zugriff-auf-die-shopware-6-api-self-hosted-no-route-found-error/71346/3 "2020-12-03T12:28:12Z")

</div>

> [@ThomasChr schrieb:](https://forum.shopware.com/profile/26204/ThomasChr "ThomasChr")
> 
> Afaik musst du da garnix aktivieren. Die Api ist immer da.
> 
> Anmelden kannst du dich z.B. mit dem User.
> 
> Probier doch mal den Link, da sollte dann denied kommen: [https://www.mein-shop.de/api/v3/product](https://www.mein-shop.de/api/v3/product)
> 
> Folgendes bekomme ich ausgegeben:
> 
> {„errors“:[{„code“:„9“,„status“:„401“,„title“:„The resource owner or authorization server denied the request.“,„detail“:„Missing \u0022Authorization\u0022 header“,„meta“:{„trace“:[{„file“:„/home/default/html/vendor/league/oauth2-server/src/AuthorizationValidators/BearerTokenValidator.php“,„line“:62,„function“:„accessDenied“,„class“:„League\OAuth2\Server\Exception\OAuthServerException“,„type“:„::“,„args“:[„Missing \u0022Authorization\u0022 header“]},{„file“:„/home/default/html/vendor/league/oauth2-server/src/ResourceServer.php“,„line“:84,„function“:„validateAuthorization“,„class“:„League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator“,„type“:„-\u003E“,„args“:[{}]},{„file“:„/home/default/html/vendor/shopware/core/Framework/Api/EventListener/Authentication/ApiAuthenticationListener.php“,„line“:117,„function“:„validateAuthenticatedRequest“,„class“:„League\OAuth2\Server\ResourceServer“,„type“:„-\u003E“,„args“:[{}]},{„file“:„/home/default/html/vendor/symfony/event-dispatcher/Debug/WrappedListener.php“,„line“:126,„function“:„validateRequest“,„class“:„Shopware\Core\Framework\Api\EventListener\Authentication\ApiAuthenticationListener“,„type“:„-\u003E“,„args“:[{},„kernel.controller“,{}]},{„file“:„/home/default/html/vendor/symfony/event-dispatcher/EventDispatcher.php“,„line“:264,„function“:„\_\_invoke“,„class“:„Symfony\Component\EventDispatcher\Debug\WrappedListener“,„type“:„-\u003E“,„args“:[{},„kernel.controller“,{}]},{„file“:„/home/default/html/vendor/symfony/event-dispatcher/EventDispatcher.php“,„line“:239,„function“:„doDispatch“,„class“:„Symfony\Component\EventDispatcher\EventDispatcher“,„type“:„-\u003E“,„args“:[[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}],„kernel.controller“,{}]},{„file“:„/home/default/html/vendor/symfony/event-dispatcher/EventDispatcher.php“,„line“:73,„function“:„callListeners“,„class“:„Symfony\Component\EventDispatcher\EventDispatcher“,„type“:„-\u003E“,„args“:[[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}],„kernel.controller“,{}]},{„file“:„/home/default/html/vendor/shopware/core/Framework/Webhook/WebhookDispatcher.php“,„line“:88,„function“:„dispatch“,„class“:„Symfony\Component\EventDispatcher\EventDispatcher“,„type“:„-\u003E“,„args“:[{},„kernel.controller“]},{„file“:„/home/default/html/vendor/shopware/core/Framework/Event/BusinessEventDispatcher.php“,„line“:46,„function“:„dispatch“,„class“:„Shopware\Core\Framework\Webhook\WebhookDispatcher“,„type“:„-\u003E“,„args“:[{},„kernel.controller“]},{„file“:„/home/default/html/vendor/shopware/core/Framework/Event/NestedEventDispatcher.php“,„line“:32,„function“:„dispatch“,„class“:„Shopware\Core\Framework\Event\BusinessEventDispatcher“,„type“:„-\u003E“,„args“:[{},„kernel.controller“]},{„file“:„/home/default/html/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php“,„line“:168,„function“:„dispatch“,„class“:„Shopware\Core\Framework\Event\NestedEventDispatcher“,„type“:„-\u003E“,„args“:[{},„kernel.controller“]},{„file“:„/home/default/html/vendor/symfony/http-kernel/HttpKernel.php“,„line“:146,„function“:„dispatch“,„class“:„Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher“,„type“:„-\u003E“,„args“:[{},„kernel.controller“]},{„file“:„/home/default/html/vendor/symfony/http-kernel/HttpKernel.php“,„line“:80,„function“:„handleRaw“,„class“:„Symfony\Component\HttpKernel\HttpKernel“,„type“:„-\u003E“,„args“:[{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},1]},{„file“:„/home/default/html/vendor/symfony/http-kernel/Kernel.php“,„line“:201,„function“:„handle“,„class“:„Symfony\Component\HttpKernel\HttpKernel“,„type“:„-\u003E“,„args“:[{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},1,true]},{„file“:„/home/default/html/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php“,„line“:85,„function“:„handle“,„class“:„Symfony\Component\HttpKernel\Kernel“,„type“:„-\u003E“,„args“:[{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},1,true]},{„file“:„/home/default/html/vendor/symfony/http-kernel/HttpCache/HttpCache.php“,„line“:477,„function“:„handle“,„class“:„Symfony\Component\HttpKernel\HttpCache\SubRequestHandler“,„type“:„::“,„args“:[{},{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},1,true]},{„file“:„/home/default/html/vendor/symfony/http-kernel/HttpCache/HttpCache.php“,„line“:450,„function“:„forward“,„class“:„Symfony\Component\HttpKernel\HttpCache\HttpCache“,„type“:„-\u003E“,„args“:[{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},true]},{„file“:„/home/default/html/vendor/symfony/http-kernel/HttpCache/HttpCache.php“,„line“:344,„function“:„fetch“,„class“:„Symfony\Component\HttpKernel\HttpCache\HttpCache“,„type“:„-\u003E“,„args“:[{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},true]},{„file“:„/home/default/html/vendor/symfony/http-kernel/HttpCache/HttpCache.php“,„line“:222,„function“:„lookup“,„class“:„Symfony\Component\HttpKernel\HttpCache\HttpCache“,„type“:„-\u003E“,„args“:[{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},true]},{„file“:„/home/default/html/vendor/shopware/core/HttpKernel.php“,„line“:163,„function“:„handle“,„class“:„Symfony\Component\HttpKernel\HttpCache\HttpCache“,„type“:„-\u003E“,„args“:[{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},1,true]},{„file“:„/home/default/html/vendor/shopware/core/HttpKernel.php“,„line“:80,„function“:„doHandle“,„class“:„Shopware\Core\HttpKernel“,„type“:„-\u003E“,„args“:[{„attributes“:{},„request“:{},„query“:{},„server“:{},„files“:{},„cookies“:{},„headers“:{}},1,true]},…

---

<div class="post-metadata">

### Author: ![ThomasChr](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/thomaschr/32/10466_2.png) [@ThomasChr](https://forum.shopware.com/u/ThomasChr)
#### Post date: [3. Dezember 2020 um 12:29 UTC](https://forum.shopware.com/t/wie-aktiviere-ich-den-zugriff-auf-die-shopware-6-api-self-hosted-no-route-found-error/71346/4 "2020-12-03T12:29:21Z")

</div>

Das heißt die API ist da!

Ich kann hier nur mit Python dienen, aber mach halt das mal:

```
import json
import requests

url = 'https://www.mein-shop.de'
userid = 'xxx'
userpass = 'yyy'

artnr = '123'

##### LOGIN #####
requrl = url + '/api/oauth/token'
payload = {'client_id': 'administration', 'grant_type': 'password', 'scopes': 'write', 'username': userid, 'password': userpass}
r = requests.post(requrl, json=payload)
r = json.loads(r.text)
token = r['access_token']

##### GET PRODUCT_BY_ARTNR #####
requrl = url + '/api/v3/product' + '?filter[product.productNumber]=' + artnr
headers = {'Accept': 'application/json', 'Authorization' : 'Bearer ' + token}
r = requests.get(requrl, headers=headers)
r = json.loads(r.text)
productid = r['data'][0]['_uniqueIdentifier']

```

&nbsp;

---

<div class="post-metadata">

### Author: ![nbcoding](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@nbcoding](https://forum.shopware.com/u/nbcoding)
#### Post date: [3. Dezember 2020 um 13:00 UTC](https://forum.shopware.com/t/wie-aktiviere-ich-den-zugriff-auf-die-shopware-6-api-self-hosted-no-route-found-error/71346/5 "2020-12-03T13:00:16Z")

</div>

> [@ThomasChr schrieb:](https://forum.shopware.com/profile/26204/ThomasChr "ThomasChr")

Das heißt die API ist da!

Ich kann hier nur mit Python dienen, aber mach halt das mal:

```
import json
import requests

url = 'https://www.mein-shop.de'
userid = 'xxx'
userpass = 'yyy'

artnr = '123'

##### LOGIN #####
requrl = url + '/api/oauth/token'
payload = {'client_id': 'administration', 'grant_type': 'password', 'scopes': 'write', 'username': userid, 'password': userpass}
r = requests.post(requrl, json=payload)
r = json.loads(r.text)
token = r['access_token']

##### GET PRODUCT_BY_ARTNR #####
requrl = url + '/api/v3/product' + '?filter[product.productNumber]=' + artnr
headers = {'Accept': 'application/json', 'Authorization' : 'Bearer ' + token}
r = requests.get(requrl, headers=headers)
r = json.loads(r.text)
productid = r['data'][0]['_uniqueIdentifier']

```

&nbsp;

Super, vielen vielen Dank!

Das hat perfekt geklappt.
