Hello all,
I’m pretty new to the PD api. Trying to run a simple search requests on persons. I can run a request to /persons (fetch all) just fine but I’m getting a 401 when I try to perform a search.
successful /persons request example
curl https://sandbox.pipedrive.com/api/v1/persons?api_token=$PD_SB_KEY
{"success":true,"data":[{"id":1,"company_id":12345,...}}}
unsuccessful /persons/search request example
curl https://sandbox.pipedrive.com/api/v1/persons/search?term=new@email.com&fields=email&exact_match=true&api_token=$PD_SB_KEY
{"success":false,"error":"unauthorized access","errorCode":401}
Any guidance would be greatly appreciated.
Hello @darthly
@
is a special character in CURL and is not encoded before the request, which breaks the path and leads to 401 in the second case. If you put API token before the term with “@” then there is a different error
curl https://sandbox.pipedrive.com/api/v1/persons/search?api_token=$PD_SB_KEY&term=new@email.com&fields=email&exact_match=true&
To avoid this, please wrap a URL in a double quote (" ")
curl "https://sandbox.pipedrive.com/api/v1/persons/search?term=new@email.com&fields=email&exact_match=true&api_token=$PD_SB_KEY"
Also, I would recommend Postman as a tool for testing API requests, as it covers a lot of cases out of the box.
1 Like
Yeah that looks to be the issue. Thanks for the help @mykhailo
1 Like