CCP - Receive error '400 Bad request' using curl command
Symptom
Sample curl command in a lab environment:
curl -vk 'https://pvwa01.demo.local/AIMWebService/api/accounts?AppId=Test-App01&Query=Safe=Test Safe;Object=Operating System-CYBRUnixviaSSHAccounts-1.1.1.1-root02'
Using the curl command above on a client machine to retrieve the credentials resulted in the following error:
Environment
10.5;10.6;10.7;10.8;10.9;10.10;11.1;11;11.2;11.3;11.4;11.5;11.6;11.7;12.0
Central Credential Provider
Curl Command
Cause
'HTTP Error 400. The request is badly formed'
In this particular example, the error appeared due to a mistyped URL when issuing the curl command:
curl -vk 'https://pvwa01.demo.local/AIMWebService/api/accounts?AppId=Test-App01&Query=Safe=Test Safe;Object=Operating System-CYBRUnixviaSSHAccounts-1.1.1.1-root02'
There is a space between 'Test' and 'Safe' as well as 'Operating' and 'System' in the URL address of the curl command.
Resolution
A URL must not contain a literal space and it must be encoded (e.g. adding %20 to represent a space).
The following is an example to resolve HTTP error 400:
curl -vk 'https://pvwa01.demo.local/AIMWebService/api/accounts?AppId=Test-App01&Query=Safe=Test%20Safe;Object=Operating%20System-CYBRUnixviaSSHAccounts-1.1.1.1-root02'