abuzuhri / Amazon-SP-API-CSharp

.Net C# library for the new Amazon Selling Partner API
MIT License
217 stars 191 forks source link

_UPLOAD_VAT_INVOICE_ sample ? #733

Closed Kestukas closed 6 months ago

Kestukas commented 6 months ago

Hello all, is there any sample for _UPLOAD_VATINVOICE ? , because i did not found how to post non XML file contents

GWPOPP commented 6 months ago

Hello, you could use "SubmitFeed" from "FeedService". There is a parameter called "XmlContentOrFilePath", which, as the name suggests, also accepts a file path to the PDF file. Params are: XmlContentOrFilePath = File path feedType = Utils.Constants.FeedType.UPLOAD_VAT_INVOICE feedOptions = New AmazonSpApiSDK.Models.Feeds.FeedOptions From { {"metadata:documenttype", "Invoice"}, {"metadata:invoicenumber", ?}, {"metadata:totalAmount", ?, {"metadata:totalvatamount", ?}} contentType = Utils.Constants.ContentType.PDF marketPlaceIds = Affected marketplace

Hope this helps.

Kestukas commented 6 months ago

Thank you! it worked, part of code 👍

AmazonCredential cred = new AmazonCredential() { AccessKey = AmazonSP_Settings.AccessKey, SecretKey = AmazonSP_Settings.SecretKey, RoleArn = AmazonSP_Settings.RoleArn, ClientId = AmazonSP_Settings.ClientId, ClientSecret = AmazonSP_Settings.ClientSecret, RefreshToken = AmazonSP_Settings.RefreshToken, MarketPlace = MarketPlace.GetMarketPlaceByID(marketplaceId) };

AmazonConnection amazonConnection = new AmazonConnection(cred);

var task1 = DownloadPdfAsync(InvocieLink); task1.Wait(); byte[] pdfBytes = task1.Result;

var tempFilePath = OrderID + ".pdf"; File.WriteAllBytes(tempFilePath, pdfBytes);

FeedOptions feedOptions = new FeedOptions();

feedOptions.Add("metadata:OrderId", OrderID); feedOptions.Add("metadata:documenttype", "Invoice"); feedOptions.Add("metadata:InvoiceNumber", InvoiceNumber);

var feedID = amazonConnection.Feed.SubmitFeed(tempFilePath, FeedType.UPLOAD_VAT_INVOICE, null, feedOptions, ContentType.PDF);