- This topic has 1 reply, 2 voices, and was last updated 1 month, 1 week ago by
April 24, 2020 at 1:25 pm #222168ParticipantTopics: 2Replies: 0Points: 12Rank: Member
To explain you the design, I’ve built an API for Amazon AMS. I export data automatically.
I now have a problem with Automatically follow redirects. When I run my script via POSTMAN, I can download my data, because I could disable the Automatically follow redirects option in the POSTMAN software, so my GET request uses the HTTP 307 redirect.
So I tried in powershell to do the same method:
Here is my command line:
$response = Invoke-RestMethod ‘https://advertising-api-eu.amazon.com/v2/reports/amzn1.clickXXXX/download’ -Method ‘GET’ -Headers $headers -MaximumRedirection 0
But I have nothing, no data, I thought MaximumRedirection 0 allowed to do as in POSTMAN but I don’t understand anymore.
Do you have ideas to help me?
I give you in screenshot the PSOTMAN parameter that allowed me to get what I want.
Thank you in advance.
April 24, 2020 at 2:19 pm #222177ParticipantTopics: 12Replies: 1622Points: 2,560Rank: Community Hero
I’m assuming it’s a typo that there is a semi-colon at the end of the uri, otherwise it would be considered the end of the line and you’d be seeing other errors. Here are some links I found:
The documentation does state that 0 should stop all redirection:
Specifies how many times PowerShell redirects a connection to an alternate Uniform Resource Identifier (URI) before the connection fails. The default value is 5. A value of 0 (zero) prevents all redirection.
If you want to see what headers are coming back, you typically need to use Invoke-WebRequest as Invoke-RestMethod doesn’t return header information. The latest version of Powershell is supposed have some capabilities to see response codes, but haven’t played with it.
- You must be logged in to reply to this topic.