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

Get-EdnsZoneTransferStatus 417 issue #3

Open
JG237 opened this issue Jun 28, 2024 · 9 comments
Open

Get-EdnsZoneTransferStatus 417 issue #3

JG237 opened this issue Jun 28, 2024 · 9 comments

Comments

@JG237
Copy link

JG237 commented Jun 28, 2024

Hi,
When I first connect to Akamai I can not run the Get-EdnsZoneTransferStatus for about 10 minutes
every other command works

status 417
Expect 100-contiune header is not supported

image

@michal-krobicki-akamai
Copy link
Collaborator

Hi @JG237 ,

Please describe your use case in more detail.
I am especially curious about the 10 minutes. It is 10 minutes after what event?
If you are running this in a script then please share your code if possible.

The function seems to work as expected in general.
image

@JG237
Copy link
Author

JG237 commented Jul 1, 2024

Hi @michal-krobicki-akamai

I can connect to Akamai and run any of the get-Edns* command and I get results fine
It is only the Get-EdnsZoneTransferStatus that has this error.
After "5-10" minutes it just starts working with no issues. I don't change anything. Then works until I close the PS session

What is the @testParams you are using

Here is a cutdown version of the script I am running.
New-AkamaiSession -ClientSecret $clientsec -HostName $myhost -ClientAccessToken $myaccesstoken -ClientToken $myclienttoken
$akamaiDNS_Sec = Get-EdnsZone | where {$_.type -match "secondary"}
Foreach ($DNSAkaSec in $akamaiDNS_Sec) {
$transferinfo = Get-EdnsZoneTransferStatus -Zones $($DNSAkaSec.zone)
$tranmstip = $transferinfo.masters.masterip
$AkaSOASer = $transferinfo.metadata.lastSuccessSerial
write-host "$($DNSAkaSec.zone) - $AkaSOASer"
}

@michal-krobicki-akamai
Copy link
Collaborator

michal-krobicki-akamai commented Jul 2, 2024

Hi @JG237,

  • First of all - in majority of cases, the individual Get-* functions are only used to set the right path for each API call and validate/format input and output. Also, majority of these function use HTTP GET method.
    Get-EdnsZoneTransferStatus is different as it uses POST.
  • All of the functions use the same Invoke-AkamaiRestMethod from Akamai.Common behind the scenes, which is responsible for authorization, HTTP header management etc.
    The error in your screenshot suggests that the function fails due to Expect: 100 - Continue HTTP header being present in your request.
    It is a known scenario with Akamai OpenAPIs and Invoke-AkamaiRestMethod includes code to disable that header for all POST and PUT calls:
    # Add additional headers if POSTing or PUTing
    If ($Body) {
        # turn off the "Expect: 100 Continue" header
        # as it's not supported on the Akamai side.
        [System.Net.ServicePointManager]::Expect100Continue = $false
    }

Can you think of any reason how such header may be added to your request?
Is there a proxy that modifies your requests and adds it?
What is the PowerShell version you are using to run your code?
Can you test the script from a different machine / network?

@JG237
Copy link
Author

JG237 commented Jul 4, 2024

For me it is very strange as it only occurs for the first 5-10 minutes of the session the rest of the day it is 100% fine.
Access should not change
Also PS command don't change.
I tested on 3 machines and get the same result.

PSVersion 5.1.20348.2400

@Senopratomo
Copy link

Hi @JG237 ,

I think the problem is due to PS version 5.xxx is sending "Expect: 100-continue" by default on POST request.
found couple of articles that mentioned about it:
https://stackoverflow.com/questions/73423825/invoke-webrequest-getting-401-unauthorized-only-with-powershell-5-1
https://hochwald.net/invoke-webrequest-and-invoke-restmethod-get-401-unauthorized-without-any-reason/

Could you try run your PS1 script on latest Powershell ?

cheeeers!

@stuart-macleod-akamai
Copy link
Collaborator

Invoke-AkamaiRestMethod only removes Expect:100-Continue if there is a request body, rather than purely based on the method. So it might be that somehow there is no body in your use case. I have seen weirdness where foreach loops have executed even though the input collection is null, but have never gotten to the bottom of it. We will test with an empty input body to see if this triggers the issue, but @JG237 can you add some reporting to your script to print $DNSAkaSec.zone every time it runs? We might need to add some validation remove that behaviour purely based on method, rather than presence of Body

@stuart-macleod-akamai
Copy link
Collaborator

Hi @JG237 ,

I think the problem is due to PS version 5.xxx is sending "Expect: 100-continue" by default on POST request. found couple of articles that mentioned about it: https://stackoverflow.com/questions/73423825/invoke-webrequest-getting-401-unauthorized-only-with-powershell-5-1 https://hochwald.net/invoke-webrequest-and-invoke-restmethod-get-401-unauthorized-without-any-reason/

Could you try run your PS1 script on latest Powershell ?

cheeeers!

Testing on PS 7.4+ is always a good idea, but even on PS 5.1 the Akamai module removes 100-continue

@stuart-macleod-akamai
Copy link
Collaborator

Hi @JG237,

We've released version 2.1, which includes a change to remove the scoping on the 100-continue removal. Can you upgrade and test on 2.1 and let me know how that goes?

Thanks

@JG237
Copy link
Author

JG237 commented Aug 27, 2024

Hi @stuart-macleod-akamai,

My script picked up the new version and updated the modules to 2.1 last week,
It has not failed since.

Thank you for the update.

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

No branches or pull requests

4 participants