'Error cURL AbuseIPDB through Powershell Command - Cannot bind parameter 'Headers'

I'd like to ask about cURL command for AbuseIPDB, as stated in https://docs.abuseipdb.com/#check-endpoint

So I tried to run the command with the following Powershell curl command"

curl -G https://api.abuseipdb.com/api/v2/check \  --data-urlencode "ipAddress=118.25.6.39" \  -d maxAgeInDays=90 \  -H "Key: $MYKEY" \  -H "Accept: application/json"

However, I received the following error description:

Invoke-WebRequest : Cannot bind parameter 'Headers'. Cannot convert the "Key: " value of type "System.String" to type "System.Collections.IDictionary".
At line:1 char:120
+ ... ys=90 \  -H "Key: $MYKEY ...
+                 ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I wonder what I did wrong in here? Thank you very much for the pointers/ answers.



Solution 1:[1]

The headers argument is supposed to receive a dictionary (once), not a string (multiple times), e.g.

curl ... -H @{ "Key" = "$MYKEY"; "Accept" = "application/json" }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hlovdal