Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Describe the bug
When trying to upload an image file using the Upload endpoint, I get an error:

sp_api.base.exceptions.SellingApiForbiddenException: [{'code': 'Unauthorized', 'message': 'Access to requested resource is denied.', 'details': ''}]

To Reproduce

I'm running this script:

from sp_api.api import Upload
from sp_api.base import Marketplaces
from PIL import Image

credentials = dict(
    lwa_app_id="xxx",
    lwa_client_secret="xxx",
    aws_access_key="xxx",
    aws_secret_key="xxx",
    refresh_token="xxx"
)

u = Upload(
    marketplace=Marketplaces.ES,
    credentials=credentials,
)
res = u.upload_document(resource="/aplus/2020-11-01/contentDocuments", file=image_path, content_type="image/png")

The exact error message:

Traceback (most recent call last):
  File "/home/til/code/monorepo/src/mpm/mahler.py", line 714, in <module>
    main()
  File "/home/til/code/monorepo/src/mpm/mahler.py", line 701, in main
    m.acm_es.upl.upload_document(resource="/uploads/v1/uploadDestinations/aplus/2020-11-01/contentDocuments", file="playground/test.png")
  File "/home/til/.local/lib/python3.11/site-packages/sp_api/base/helpers.py", line 21, in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/til/.local/lib/python3.11/site-packages/sp_api/api/upload/upload.py", line 15, in upload_document
    return self._request(fill_query_params(kwargs.pop('path'), resource), params=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/til/.local/lib/python3.11/site-packages/sp_api/base/client.py", line 157, in _request
    return self._check_response(res, res_no_data, bulk, wrap_list)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/til/.local/lib/python3.11/site-packages/sp_api/base/client.py", line 183, in _check_response
    raise exception(error, headers=res.headers)
sp_api.base.exceptions.SellingApiForbiddenException: [{'code': 'Unauthorized', 'message': 'Access to requested resource is denied.', 'details': ''}]

Expected behavior

No errors + successful upload.

Desktop (please complete the following information):
Arch Linux, Kernel 6.1.38-2 LTS
Python 3.11.3 64 bit

Additional context
I'm running a fresh setup of my policies, roles, and user. All token are valid and work, eg. when using the AplusContent endpoint. Most importantly I have the Product Listing role.

I reference the endpoint used in the example docs by Amazon.

Are there any other permissions I need?

You must be logged in to vote

Replies: 6 comments · 4 replies

Comment options

Converted to discussion since it’s unrelated to the library.

You must be logged in to vote
4 replies
@tilschuenemann
Comment options

I'd usually test both methods createUploadDestinationForResource and upload my file to that destination, but my impression is that the library manages both of these steps and therefore this issue is related to the library?

@tilschuenemann
Comment options

@saleweaver Can you comment on this or does this lean too much into consulting? We'd be happy to get closure on this.

@bbenda02
Comment options

Yeah, can we get some clarification on this? I'm stuck up on this issue as well.

@bbenda02
Comment options

Have you figured anything out on this issue?

Comment options

the resource should be "aplus/2020-11-01/contentDocuments" and not "/aplus/2020-11-01/contentDocuments" without the backslash in the begining.

You must be logged in to vote
0 replies
Comment options

I also made the same mistake. How did you solve it

You must be logged in to vote
0 replies
Comment options

I also made the same mistake. How did you solve it

You must be logged in to vote
0 replies
Comment options

I also made the same mistake. How did you solve it

You must be logged in to vote
0 replies
Comment options

I also made the same mistake. How did you solve it

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
FAQ
Labels
bug Something isn't working
5 participants
Converted from issue

This discussion was converted from issue #1115 on July 20, 2023 12:20.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.