Why does a queryResults REST request get a 403 Forbidden error?
If a queryResults request URL like below is used in a browser rest client:
https://examplesite.custhelp.com/services/rest/connect/latest/queryResults/?query=SELECT LookupName FROM Contact WHERE LookupName LIKE '%test%'
A user can get a "Status Code: 403 Forbidden" error and no response will be there. This is because URL used on the request is not fully URL encoded. The full request command can be like below:
curl -X GET -k -H 'OSvC-CREST-Application-Context: Good' -H 'Authorization: Basic REMOVED' -i 'https://examplesite.custhelp.com/services/rest/connect/latest/queryResults/?query=SELECT LookupName FROM Contact WHERE LookupName LIKE '\''%test%'\'
If that command is run, the curl command throws the error, "Status Code: 403 Forbidden" and the request will be not sent.
To avoid that error, get the request sent, and the expected results returned, the URL entered needs to be fully URL encoded. For the above query that would be:
https://examplesite.custhelp.com/services/rest/connect/latest/queryResults/?query=SELECT%20LookupName%20FROM%20Contacts%20WHERE%20LookupName%20LIKE%20'%25test%25'
If a request is properly URL encoded, sent, and does encounter an error from here, an error response and headers would be returned.