Amazon-SP-API-CSharp
Amazon-SP-API-CSharp copied to clipboard
Orders.GetOrders() is returning "Empty target resource argument found error" after updating library Version 1.7.2 > 1.7.18
My application was using 1.7.2. I upgraded to 1.7.18 and Orders.GetOrders() stopped working. It is now returning "Empty target resource argument found error" no matter what inputs I give it. I have not had time to dive into this. If I get time and can figure it out I will post here. I wanted to say something now in case you or someone else knows what has changed recently.
I was able to downgrade back to 1.7.2 for now. I tried to downgrade to 1.7.10 to see if I could figure out which update broke it. 1.7.10 threw the error as well. It is somewhere between .2 and .10.
AmazonConnection connection = new AmazonConnection(new AmazonCredential()
{
AccessKey = ConfigurationManager.AppSettings["accessKey"],
SecretKey = ConfigurationManager.AppSettings["secretKey"],
RoleArn = ConfigurationManager.AppSettings["roleARN"],
ClientId = ConfigurationManager.AppSettings["clientId"],
ClientSecret = ConfigurationManager.AppSettings["clientSecret"],
RefreshToken = ConfigurationManager.AppSettings["refreshToken"],
MarketPlace = MarketPlace.US
});
var parameterOrderList = new ParameterOrderList
{
CreatedAfter = DateTime.UtcNow.AddHours(-120),
OrderStatuses = new List<OrderStatuses> { OrderStatuses.Unshipped },
MarketplaceIds = new List<string> { MarketPlace.US.ID },
IsNeedRestrictedDataToken = true
};
var amazonOrders = connection.Orders.GetOrders(parameterOrderList);
I am also experiencing this issue.
I removed the AccessKey, SecretKey and RoleARN as they are no longer required. However, when I set IsNeedRestrictedDataToken to true I get that same message.
When IsNeedRestrictedDataToken is false I do get orders data successfully.
Just to confirm - I can accomplish this via Postman without an issue
Further update - when I added this:
RestrictedDataTokenRequest = new CreateRestrictedDataTokenRequest { restrictedResources = new List<RestrictedResource> { new RestrictedResource { method = Method.GET.ToString(), path = ApiUrls.OrdersApiUrls.Orders, dataElements = new List<string> { "buyerInfo", "shippingAddress" } } } }
To my params, it works.
Unfortunately this is not a complete solution. If the GetOrders call will return > 100 orders then the orders after the first 100 will not have the PII data in. I.e. the first call is fine, but if a NextToken is retuned then the subsequent requests have no PII data returned. I.e. the GetGetOrdersByNextTokenAsync function is not using the RestrictedDataToken
Was there a fix for this error, as I upgraded ver 1.7.27 today and have the same issue? Thanks
Was there a fix for this error, as I upgraded ver 1.7.27 today and have the same issue? Thanks
I was able overcome the issue by removing IsNeedRestrictedDataToken = true BUT then get the address by using GetOrderAddress
OrderAddress OrderAddress = amazonConnection.Orders.GetOrderAddress(order.AmazonOrderId);
Has this bug been fixed? I'm stuck on version 1.7.9, unable to update to a higher version because as soon as I do, this problem appears again.
Further update - when I added this:
RestrictedDataTokenRequest = new CreateRestrictedDataTokenRequest { restrictedResources = new List<RestrictedResource> { new RestrictedResource { method = Method.GET.ToString(), path = ApiUrls.OrdersApiUrls.Orders, dataElements = new List<string> { "buyerInfo", "shippingAddress" } } } }To my params, it works.
Hello brother, have you been able to retrieve the address recently?
Was there a fix for this error, as I upgraded ver 1.7.27 today and have the same issue? Thanks
I was able overcome the issue by removing IsNeedRestrictedDataToken = true BUT then get the address by using GetOrderAddress
OrderAddress OrderAddress = amazonConnection.Orders.GetOrderAddress(order.AmazonOrderId);
Hello brother, have you been able to retrieve the address recently?
Was there a fix for this error, as I upgraded ver 1.7.27 today and have the same issue? Thanks
I was able overcome the issue by removing IsNeedRestrictedDataToken = true BUT then get the address by using GetOrderAddress OrderAddress OrderAddress = amazonConnection.Orders.GetOrderAddress(order.AmazonOrderId);
Hello brother, have you been able to retrieve the address recently?
The most similar to a workaround is:
var conexion = AmazonApiOrdersService.ConexionAmazon();
var orders = await conexion.Orders.GetOrdersAsync(searchOrderList).ConfigureAwait(false);
foreach (var orderAdresss in orders)
{
var address = await conexion.Orders.GetOrderAddressAsync(orderAdresss.AmazonOrderId).ConfigureAwait(false);
orderAdresss.ShippingAddress = address.ShippingAddress;
}
return orders;
The most similar to a workaround is:
var conexion = AmazonApiOrdersService.ConexionAmazon(); var orders = await conexion.Orders.GetOrdersAsync(searchOrderList).ConfigureAwait(false); foreach (var orderAdresss in orders) { var address = await conexion.Orders.GetOrderAddressAsync(orderAdresss.AmazonOrderId).ConfigureAwait(false); orderAdresss.ShippingAddress = address.ShippingAddress; } return orders;
This is the best solution when there is > than 100 orders. For the first 100 orders you can manually add the Restricted Data Token:
RestrictedDataTokenRequest = new CreateRestrictedDataTokenRequest { restrictedResources = new List<RestrictedResource> { new RestrictedResource { method = Method.GET.ToString(), path = ApiUrls.OrdersApiUrls.Orders, dataElements = new List
It is the GetGetOrdersByNextTokenAsync function which does not use the RestrictedDataToken
@abuzuhri can we please get a fix of this error? I updated to 1.8.1 Version and starting getting this error.
Having the same issue. Buyers information isn't populating either when passing "buyerInfo" to the dataelements for restricted resource.
I need help from some one with access token for testing for if some one can solve it and submit the change to merge