Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting getting LWA Access Token Error while posting Shipment tracking on amazon #727

Open
asifiq2000 opened this issue Apr 15, 2024 · 3 comments

Comments

@asifiq2000
Copy link

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.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);

image_2024_04_15T03_21_23_957Z

@ismkdc
Copy link
Contributor

ismkdc commented Apr 17, 2024

same problem i have

@kevinvenclovas
Copy link
Contributor

kevinvenclovas commented Apr 22, 2024

@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,
    }
});

@asifiq2000
Copy link
Author

Hi @abuzuhri

I have implemented the POST_ORDER_FULFILLMENT_DATA API posting through FIKA
First I send the tracking detail on amazon through FIKA using below method

createDocument.AddOrderFulfillmentMessage(list);
var xml = createDocument.GetXML();
string feedID = amazonConnection.Feed.SubmitFeed(xml, FeedType.POST_ORDER_FULFILLMENT_DATA);

which is running fine, but when I Post the tracking through SubmitFeed() method as mentioned above I get the FeedID
from amazon
then I make a new request to get the Status of that FeedID through the below method:

feedOutput=amazonConnection.Feed.GetFeed(mFeedID);
if(feedOutput.ResultFeedDocumentId is not null)
{
var outPut=amazonConnection.Feed.GetFeedDocument(feedOutput.ResultFeedDocumentId);
if (outPut is not null)
{
var processingReport = amazonConnection.Feed.GetFeedDocumentProcessingReport(outPut.Url);
resultCatalogFeed.FeedSubbmisionID = processingReport.DocumentTransactionID;
resultCatalogFeed.TotalProductSubmited =
Convert.ToInt32(processingReport.ProcessingSummary.MessagesProcessed);
resultCatalogFeed.SuccessCount =
Convert.ToInt32(processingReport.ProcessingSummary.MessagesSuccessful);
resultCatalogFeed.ErrorCount =
Convert.ToInt32(processingReport.ProcessingSummary.MessagesWithError);
resultCatalogFeed.StatusCode = processingReport.StatusCode;
}}
then I am getting the posting date but not getting the posting date with Time
since our client complaining about the delay in tracking update on amazon, I am unable to find out
the update time in our system, coz status response does not have that, so please help me how to get that detail.
Is anything wrong I am doing in this, please suggest. Kindly help me ASAP, Its urgent, Thanks in Advance

Note: Our client asked me to create support ticket on amazon that why we are not getting the tracking update time
in response so amazon asking us to provide all the request details url, endpoint, parameters, headers, and payload then
they will check and answer our query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants