Can't POST Person with Sandbox api key

Hello, I am using pipedrive API with Python.
I would like to create (POST) a Person, how to do it please ? I am using the Sandbox account API KEY but it gives me 401 !

req = requests.post(url='https://api.pipedrive.com/v1/persons&api_token='+key, headers={"Accept": "application/json"}, data={"name": 'test')

<Response [401]>

I’m not using OAuth or callBackUrl because I am running a Python app (with ‘requests’ library to GET, POST and PUT data) from a windows session (on VPS) not online…

Help me please :slight_smile:

Hello Theo,

If you are using the Sandbox API token for authentication that should be fine, the problem should be elsewhere. Please note that custom fields and all fields in general have an API key and also an ID. In some instances you need one, in some other instances you need the other. But if you feed the API key when the ID is being requested, this will result in an error. Perhaps this tutorial can help with some other details: https://pipedrive.readme.io/docs/updating-custom-field-value

Cheers

Thanks I have edited my message, it occurs with a simple POST request and sandbox api key… The 401 means I’m not authorized… why ?

Moreover, I don’t understand what you call UrlCallback (required) in the submission form, I don’t have any url because my app is not web based. What to do then please ?

This topic partially answers the question : I can’t use OAuth with offline python app. OAuth and redirect_uri in offline Python script

Is there a way to do POST requests with Python offline apps please ?

Hi @Theo175,
I don’t know if there are also other issues in your app, but this is one:
'https://api.pipedrive.com/v1/persons&api_token='+key
should be
'https://api.pipedrive.com/v1/persons?api_token='+key

(Note the ? instead of the &).

If you have other query parameters to pass after the api_token, you can then use & to separate them.

Hope that helps.

1 Like

I’m curious if this resolved Theo’s issue, hopefully he’ll respond with some new attention to his post, though Dani I did want to ask a similar question. Can a python app which isn’t directly hosted online (aka has no fixed return url) access the API? What would you specify in the return at that point or can it support it at all? It simplified security if API/programmatic access was just available in some offline solution which can be shut down and not hosted externally.

Hi @Skyler_Saleebyan

There is no need to have some “live” server to call Public Pipedrive API. You can use API token (go to Pipedrive → /settings/api). More about API here About the Pipedrive API