amz-tools / amazon-sp-api

Amazon Selling Partner API Client
MIT License
231 stars 119 forks source link

Unable to access to sandbox #145

Open sandalija opened 2 years ago

sandalija commented 2 years ago

Hi guys!

I'm trying to connect to the sandbox environment. However, every time I try it, I receive an error message. If I make a API call to the normal environment, it works successfully. I.e, I have this error for order.getOrders.

let orders = await sellingPartner.callAPI({
        operation: 'orders.getOrders',
        query: {
          MarketplaceIds: 'A1RKKUPIHCS9HS',
          CreatedAfter: '2022-01-01',
          OrderStatuses: 'Unshipped',
        },
        options: {
          version: 'v0',
        },
      })
      let order
      console.log({orders})

orders value is

orders: [
    {
      code: 'InvalidInput',
      message: 'Could not match input arguments'
    }
  ]

I create the SDk object like this:

const sellingPartner = new SellingPartnerAPI({
    region: 'eu', // The region to use for the SP-API endpoints ("eu", "na" or "fe")
    refresh_token:
      'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    credentials: {
      SELLING_PARTNER_APP_CLIENT_ID:
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      SELLING_PARTNER_APP_CLIENT_SECRET:
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      AWS_ACCESS_KEY_ID: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      AWS_SECRET_ACCESS_KEY: 'xxxxxxxxxxxxxxxxxxxxx',
      AWS_SELLING_PARTNER_ROLE:
        'arn:aws:iam::xxxxxxxxxxxx:rolw/xxxxxxxxx',
    },
    options: {
      use_sandbox: true
    }
  })

I don't rule out that it's my fault, I'm pretty new to the Amazon SP API. If so, I would like to improve the README for sandbox mode.

FYI: I'm using amazon-sp-api@0.7.8 on node 12

amz-tools commented 2 years ago

HI @sandalija,

the problem is probably that you can't use any value as input when using the sandbox. You would have to take a look at the model and search for x-amzn-api-sandbox. This will tell you what input you need to pass in for the corresponding endpoint.

ericblade commented 1 year ago

the 'sandbox' is pathetically useless, it is not a sandbox, it only takes very specific queries and returns the documented responses.