Amazon-SP-API-CSharp
Amazon-SP-API-CSharp copied to clipboard
Getting getting LWA Access Token Error while posting Shipment tracking on amazon
Hi @abuzuhri,
I am using the SP-API shipping tracking using the FIKA API
POST_ORDER_FULFILLMENT_DATA method to post the shipment on amazon but it is throwing below mentioned error, kindly suggest.
Error Detail: Exception has occurred: CLR/System.SystemException An exception of type 'System.SystemException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Error getting LWA Access Token' Inner exceptions found, see $exception in variables window for more details. Innermost exception System.IO.IOException : Unsuccessful LWA token exchange at FikaAmazonAPI.AmazonSpApiSDK.Runtime.LWAClient.<GetAccessTokenAsync>d__15.MoveNext()
code detail:
public String PostAmazonShipmentTracking(string mRefreshToken, string mSellerID, string mAmazonOrderID, string mCarrierName, string mShippingMethod, string mShipperTrackingNumber, string mCarrierCode, string mClientId, string mClientSecret) { //MarketPlace = MarketPlace.GetMarketPlaceByID("ATVPDKIKX0DER"), AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential() { AccessKey = "XXX", SecretKey = "XXX", RoleArn = "XXX", ClientId = mClientId, ClientSecret = mClientSecret, RefreshToken = mRefreshToken, MarketPlace = MarketPlace.GetMarketPlaceByID(mSellerID), });
ConstructFeedService createDocument = new ConstructFeedService(mSellerID, "1.02");
var list = new List<OrderFulfillmentMessage>();
list.Add(new OrderFulfillmentMessage()
{
AmazonOrderID = mAmazonOrderID,
//FulfillmentDate = DateTime.UtcNow.ToString(),
FulfillmentDate = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss.fffK"),
FulfillmentData = new FulfillmentData()
{
CarrierCode = mCarrierName,
CarrierName = mCarrierName,
ShippingMethod = mShippingMethod,
ShipperTrackingNumber = mShipperTrackingNumber
}
});
createDocument.AddOrderFulfillmentMessage(list);
var xml = createDocument.GetXML();
string feedID = amazonConnection.Feed.SubmitFeed(xml, FeedType.POST_ORDER_FULFILLMENT_DATA);
same problem i have
@ismkdc @asifiq2000 Hey, i think there is a problem with your credentials.
Try to remove the AccessKey, SecretKey and RoleArn from your AmazonCredential, with the refreshtoken you need this information anymore and check your ClientId ,ClientSecret and RefresToken again.
new AmazonCredential()
{
ClientId = 'XXX',
ClientSecret = 'XXX',
RefreshToken = 'XXX',
MarketPlace = MarketPlace.Germany
};
You can also try to remove CarrierName and ShippingMethod from FulfillmentData. I used it like this without any issues.
list.Add(new OrderFulfillmentMessage()
{
AmazonOrderID = order.AmazonOrderId,
FulfillmentDate = order.ShippingTime,
FulfillmentData = new FulfillmentData()
{
CarrierCode = order.Carrier,
ShipperTrackingNumber = order.Trackingnumber,
}
});