MediaMath / t1-python

Python SDK for MediaMath Platform APIs
https://developer.mediamath.com/
Apache License 2.0
18 stars 28 forks source link

ClientError: "No POST data", but passed along properties. #131

Closed robrechtdr closed 7 years ago

robrechtdr commented 7 years ago

Using version with latest commit: https://github.com/MediaMath/t1-python/commit/4703da8b4e32ac028a68caa1fa05ea9e51159e7c

As suggested in the bottom of the https://github.com/MediaMath/t1-python#entities in the documentation:

new_properties = {
         'name': 'some_agency_name',
         'organization_id': 19112,
         'status':1
}
new_agency = t1.new('agency', properties=new_properties)
new_agency.save()

Traceback (most recent call last):
  File "/Users/rrouck/pi-automation-api/automation_api/runners.py", line 302, in create_agencies
    new_agency.save()
  File "/Users/rrouck/.virtualenvs/pi-automation-api-t1test/lib/python2.7/site-packages/terminalone/entity.py", line 205, in save
    entity, _ = super(Entity, self)._post(self._get_service_path(), url, data=data)
  File "/Users/rrouck/.virtualenvs/pi-automation-api-t1test/lib/python2.7/site-packages/terminalone/connection.py", line 188, in _post
    raise ClientError('No POST data.')
ClientError: 'No POST data.'

Looking through the SDK code shows me that it fails here: https://github.com/MediaMath/t1-python/blob/4703da8b4e32ac028a68caa1fa05ea9e51159e7c/terminalone/connection.py#L190.

Looks like the properties data is not propagating to the post call somehow.

FodT commented 7 years ago

Welp, Looks like the last update has broken creating new entities entirely (using the properties argument on construct)

Workaround for the time being would be to set each property explicitly and avoid using the properties argument.

robrechtdr commented 7 years ago

Just going to use the version from the commit before (https://github.com/MediaMath/t1-python/commit/09cdf1a6742b9a26ed07a40e39b96a3d0571f063).

I assume this will use the new endpoints and not the deprecated ones (https://developer.mediamath.com/docs/read/terminalone_api_overview/Upcoming_API_Migrations).

robrechtdr commented 7 years ago

@FodT We are currently using a fork that doesn't include the changes which create this issue. Would it be possible to put this issue in the backlog under projects (can't see it there currently) so it gets fixed soon and we can start pulling from your repo again when a new problem arises and there's a fix?

FodT commented 7 years ago

Resolved by #136