Forum Discussion
ChrisSchroeder
Mar 19, 2021Copper Contributor
Passing information to API, works in CURL, not in PS7
This API call to a Cisco Firepower 1120 works in CURL (on Ubuntu)... please note credentials and host name have been obfuscated here but are correct in the original versions: curl --cacert fwcert...
- Mar 19, 2021
Hello ChrisSchroeder,
I think you are missing -ContentType parameter:
If this parameter is omitted and the request method is POST, Invoke-RestMethod sets the content type to application/x-www-form-urlencoded.
Invoke-RestMethod -Uri $fwurl -Method POST -SkipCertificateCheck -Body $param -Content 'application/json'
Reference: Invoke-RestMethod
Hope that helps.
AndySvints
Mar 19, 2021Iron Contributor
Hello ChrisSchroeder,
I think you are missing -ContentType parameter:
If this parameter is omitted and the request method is POST, Invoke-RestMethod sets the content type to application/x-www-form-urlencoded.
Invoke-RestMethod -Uri $fwurl -Method POST -SkipCertificateCheck -Body $param -Content 'application/json'
Reference: Invoke-RestMethod
Hope that helps.
ChrisSchroeder
Mar 23, 2021Copper Contributor
Thank you Andy! I had tried that before in previous iterations (when obviously something else was wrong) but somewhere along the way I left it out of my testing. I appreciate your help - it works fine now!!