Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Amazon SP-API Get FeedsSee more Amazon SP-API ExamplesReturns feed details for the feeds that match the filters that you specify. For more information, see https://developer-docs.amazon.com/sp-api/docs/feeds-api-v2021-06-30-reference#get-feeds2021-06-30feeds
integer li_rc oleobject loo_AuthAws oleobject loo_Rest integer li_Success oleobject loo_JsonToken string ls_Lwa_token oleobject loo_SbResponse string ls_Path integer li_StatusCode oleobject loo_Json string ls_FeedId string ls_FeedType string ls_CreatedTime string ls_ProcessingStatus string ls_ProcessingStartTime string ls_ProcessingEndTime string ls_NextToken integer i integer li_Count_i // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_AuthAws = create oleobject // Use "Chilkat_9_5_0.AuthAws" for versions of Chilkat < 10.0.0 li_rc = loo_AuthAws.ConnectToNewObject("Chilkat.AuthAws") if li_rc < 0 then destroy loo_AuthAws MessageBox("Error","Connecting to COM object failed") return end if loo_AuthAws.AccessKey = "AWS_ACCESS_KEY" loo_AuthAws.SecretKey = "AWS_SECRET_KEY" loo_AuthAws.ServiceName = "execute-api" // Use the region that is correct for your needs. loo_AuthAws.Region = "eu-west-1" loo_Rest = create oleobject // Use "Chilkat_9_5_0.Rest" for versions of Chilkat < 10.0.0 li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest") li_Success = loo_Rest.Connect("sandbox.sellingpartnerapi-eu.amazon.com",443,1,1) if li_Success = 0 then Write-Debug loo_Rest.LastErrorText destroy loo_AuthAws destroy loo_Rest return end if li_Success = loo_Rest.SetAuthAws(loo_AuthAws) // Load the previously obtained LWA access token. // See Fetch SP-API LWA Access Token loo_JsonToken = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_JsonToken.LoadFile("qa_data/tokens/sp_api_lwa_token.json") if li_Success = 0 then Write-Debug "Failed to load LWA access token." destroy loo_AuthAws destroy loo_Rest destroy loo_JsonToken return end if // Add the x-amz-access-token request header. ls_Lwa_token = loo_JsonToken.StringOf("access_token") loo_Rest.ClearAllHeaders() loo_Rest.AddHeader("x-amz-access-token",ls_Lwa_token) loo_Rest.ClearAllQueryParams() loo_Rest.AddQueryParam("feedTypes","POST_PRODUCT_DATA") loo_Rest.AddQueryParam("pageSize","10") loo_Rest.AddQueryParam("processingStatuses","CANCELLED,DONE") loo_SbResponse = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponse.ConnectToNewObject("Chilkat.StringBuilder") ls_Path = "/feeds/2021-06-30/feeds" li_Success = loo_Rest.FullRequestNoBodySb("GET",ls_Path,loo_SbResponse) if li_Success = 0 then Write-Debug loo_Rest.LastErrorText destroy loo_AuthAws destroy loo_Rest destroy loo_JsonToken destroy loo_SbResponse return end if // Examine the response status. li_StatusCode = loo_Rest.ResponseStatusCode if li_StatusCode <> 200 then Write-Debug "Response status text: " + loo_Rest.ResponseStatusText Write-Debug "Response body: " Write-Debug loo_SbResponse.GetAsString() Write-Debug "Failed." destroy loo_AuthAws destroy loo_Rest destroy loo_JsonToken destroy loo_SbResponse return end if Write-Debug loo_SbResponse.GetAsString() // If successful, gets a JSON response such as the following: // { // "feeds": [ // { // "feedId": "FeedId1", // "feedType": "POST_PRODUCT_DATA", // "createdTime": "2019-12-11T13:16:24.630Z", // "processingStatus": "CANCELLED", // "processingStartTime": "2019-12-11T13:16:24.630Z", // "processingEndTime": "2019-12-11T13:16:24.630Z" // } // ], // "nextToken": "VGhpcyB0b2tlbiBpcyBvcGFxdWUgYW5kIGludGVudGlvbmFsbHkgb2JmdXNjYXRlZA==" // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.LoadSb(loo_SbResponse) ls_NextToken = loo_Json.StringOf("nextToken") i = 0 li_Count_i = loo_Json.SizeOfArray("feeds") do while i < li_Count_i loo_Json.I = i ls_FeedId = loo_Json.StringOf("feeds[i].feedId") ls_FeedType = loo_Json.StringOf("feeds[i].feedType") ls_CreatedTime = loo_Json.StringOf("feeds[i].createdTime") ls_ProcessingStatus = loo_Json.StringOf("feeds[i].processingStatus") ls_ProcessingStartTime = loo_Json.StringOf("feeds[i].processingStartTime") ls_ProcessingEndTime = loo_Json.StringOf("feeds[i].processingEndTime") i = i + 1 loop Write-Debug "Success!" destroy loo_AuthAws destroy loo_Rest destroy loo_JsonToken destroy loo_SbResponse destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.