jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
398 stars 185 forks source link

Exception when calling OrdersV0Api->getOrderBuyerInfo #593

Open vvp3 opened 1 year ago

vvp3 commented 1 year ago

Problem description:

Error:

Exception when calling OrdersV0Api->getOrderBuyerInfo: Failed to create restricted data token: [400] { "errors": [ { "code": "InvalidInput", "message": "Application do not have access to some or all requested resource", "details": "" } ] } NULL NULL

# Your error here. PLEASE make sure to redact secrets from your error log!

Code

// Your code here...PLEASE make sure to redact secrets from your code!

public function getOrderDetails($order_id = '') { $config = $this->_setConfig();

    $apiInstance = new SellingPartnerApi\Api\OrdersV0Api($config);

    $order_id = '408-6705626-9125157';

    try {
        $order_details = $apiInstance->getOrderBuyerInfo($order_id);

        $headers = $order_details->headers;
        print_r($headers);

        print_r($order_details);
    } catch (Exception $e) {
        echo 'Exception when calling OrdersV0Api->getOrderBuyerInfo: ', $e->getMessage(), PHP_EOL;
    }

.........

Seller Central SP API config page screenshot

your screenshot here

vvp3 commented 1 year ago

I tried do an application with Role instead of user and the response I have is the same. It seems obvious that the RTD is not generated ... how should I treat this ?

jlevers commented 1 year ago

getOrderBuyerInfo is deprecated by Amazon, please use the getOrder call with $data_elements = ['buyerInfo'] to get buyer tax information for an order. You'll need to be approved for one of the tax-related restricted roles in order to be able to retrieve tax-related PII.

vvp3 commented 1 year ago

Thank you for answer. I am working currently on making the reports work. Sadly I found that on the sales reports where the orders are shipped, I cannot even get the company VAT number. While I do not care of name email phone, I do care to get the VAT for business customers for older orders. Is there something i must add as OPTIONS to the generating of the Flat File ?

jlevers commented 1 year ago

I think you probably want either the GET_VAT_TRANSACTION_DATA or the SC_VAT_TAX_REPORT report, both of which are restricted. There's a whole guide on VAT calculation with the SP API here.

vvp3 commented 1 year ago

We have oss for a short time (july) and in july is all generated by them so i could take the data from the invoice mode, though i havent tested yet ... but before OSS it is impossible and I just need the VAT code from Amazon so I dont have to read other db or files ... I dont get why they restrict this ... becasue GDPR they hide the VAT number too ?

https://github.com/jlevers/selling-partner-api/tree/main/docs/Model/ShipmentInvoicingV0 >> i could use the data from here I think, is it with restrictions too ?

Regarding restrictions, is it something I need to ask to Amazon ? Becasue I am the root in AWS and I can have any role or just use user instead of role becasue there is none other but me.

Thank you for your patience ant time.

jlevers commented 1 year ago

Not sure what OSS is? The Shipment Invoicing V0 could work, I'm not sure. Again, I haven't worked with this data much. I think you're going to have to play around with some different endpoints and see if any of them have the data you need...The official Amazon docs might be helpful for figuring this out, as you can easily search the attributes of every model in the entire API at once through their docs site.

JosueExsim commented 1 year ago

Hi, I'm trying to fetch the buyer's name, email, and phone number through my API. The permissions for personally identifiable information (PII) are already enabled, but I'm running into an error that says: "The application doesn't have access to one or more of the requested data elements: [buyerInfo, shippingAddress]". I've tried querying separately using $data_elements = ['buyerInfo'] and $data_elements = ['shippingAddress'], but I'm getting the same error result.

Could you let me know what might be causing this issue? Just as an additional piece of information, if I send $data_elements as null, the response doesn't show the expected data, but it does return a successful response.

Thank you.

$apiInstance = new SellingPartnerApi\Api\OrdersV0Api($config); $order_id = '701-8538212-0149027'; // string | An orderId is an Amazon-defined order identifier, in 3-7-7 format. $data_elements = ['buyerInfo', 'shippingAddress'];

try { $result = $apiInstance->getOrder($order_id, $data_elements); print_r($result); } catch (Exception $e) { echo 'Exception when calling OrdersV0Api->getOrder: ', $e->getMessage(), PHP_EOL; }

xiaojinglong commented 5 months ago

Hi, I'm trying to fetch the buyer's name, email, and phone number through my API. The permissions for personally identifiable information (PII) are already enabled, but I'm running into an error that says: "The application doesn't have access to one or more of the requested data elements: [buyerInfo, shippingAddress]". I've tried querying separately using $data_elements = ['buyerInfo'] and $data_elements = ['shippingAddress'], but I'm getting the same error result.

Could you let me know what might be causing this issue? Just as an additional piece of information, if I send $data_elements as null, the response doesn't show the expected data, but it does return a successful response.

Thank you.

$apiInstance = new SellingPartnerApi\Api\OrdersV0Api($config); $order_id = '701-8538212-0149027'; // string | An orderId is an Amazon-defined order identifier, in 3-7-7 format. $data_elements = ['buyerInfo', 'shippingAddress'];

try { $result = $apiInstance->getOrder($order_id, $data_elements); print_r($result); } catch (Exception $e) { echo 'Exception when calling OrdersV0Api->getOrder: ', $e->getMessage(), PHP_EOL; }

I encountered the same problem

monoteos commented 2 months ago

same error...

Failed to create restricted data token: [400]

{
  "errors": [
    {
      "code": "InvalidInput",
      "message": "Application does not have access to one or more requested data elements: [shippingAddress]",
      "details": ""
    }
  ]
}