maxnaude / pardot-api-client

A Python client for the Pardot API
MIT License
2 stars 1 forks source link

URL encode of email address throws Code 4 on client.prospect.read #1

Open smkeesle opened 7 years ago

smkeesle commented 7 years ago

when reading prospect by email address (e.g. someone@domain.com, who exists in Pardot), the client attempts to URL encode the email address.

Traceback (most recent call last): File "./pardotapi.py", line 11, in r = client.prospect.read('someone@domain.com') File "/Users/skeesler/bin/homebrew/lib/python3.6/site-packages/pardot/resource.py", line 100, in response return self.get_response_content(request, **kwargs) File "/Users/skeesler/bin/homebrew/lib/python3.6/site-packages/pardot/resource.py", line 220, in get_response_content content = self.get_api_response(request, data=payload) File "/Users/skeesler/bin/homebrew/lib/python3.6/site-packages/pardot/resource.py", line 171, in get_api_response request) pardot.resource.PardotAPIException: Pardot API call failed with Code 4: "Invalid prospect email address" for request: https://pi.pardot.com /api/prospect/version/3/do/read/email/someone%40domain.com

However, it seems to work fine using curl: curl 'https://pi.pardot.com/api/prospect/version/3/do/read/email/someone%40domain.com?api_key=myapikey&user_key=myuserkey'

maxnaude commented 6 years ago

@smkeesle thanks for taking the time to report this.

I've not been able to reproduce the problem on Linux platforms, so hard for me to debug and guessing this might be Mac-specific.

Let me know if this still affects you, if not can we close this please?

daigotanaka commented 5 years ago

@smkeesle @maxnaude I had the same issue. I found the solution. When I inserted:

payload.pop('email') 

after Ln 213 of resource.py (payload['api_key'] = self.api_key), it worked. I don't think email and password are necessary after getting api_key upon login and it seems to be confusing Pardot API.

I was able to replicate this behavior with Postman (POST request, Content-Type: application/x-www-form-urlencoded. (But strangely, it was not a problem when I tried with curl).