Skip Navigation
REST 403 Forbidden error on queryResults request
Answer ID 12122   |   Last Review Date 03/17/2022

Why does a queryResults REST request get a 403 Forbidden error?

REST queryResults request using a browser based REST client
Client does properly URL encode the request URL
Use URL encoding on full REST queryResults requsest URL
A queryResults REST request is a standard URL GET request and it needs to have URL encoding on the whole request string. Many browser based rest clients do not properly account for this, the actual request they generate is not fully URL encoded, and it fails before it is actually sent.

If a queryResults request URL like below is used in a browser rest client: 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 ' 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:'%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.