Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

delete() response in campaign shows parse error #113

Open
rituraj17 opened this issue May 24, 2019 · 0 comments
Open

delete() response in campaign shows parse error #113

rituraj17 opened this issue May 24, 2019 · 0 comments

Comments

@rituraj17
Copy link

Using the Campaign Sample code which I have taken the form object sample of fuelsdk-python git repo

After creating a new campaign with the following description

        {
            "description": "PythonSDKCreatedForTest",
            "favorite": false,
            "createdDate": "2019-05-24T03:50:01",
            "modifiedDate": "2019-05-24T03:50:02",
            "color": "FF9933",
            "id": "361",
            "campaignCode": "PythonSDKCreatedForTest",
            "name": "PythonSDKCreatedForTest"
        }

And then deleting the campaign by executing the following code

# Delete the new Campaign
print( '>>> Delete the new Campaign')
deleteCamp = ET_Campaign()
deleteCamp.auth_stub = stubObj
deleteCamp.props = {"id": "361"}
deleteResponse = deleteCamp.delete()
print( 'Delete Status: ' + str(deleteResponse.status))
print( 'Code: ' + str(deleteResponse.code))
print( 'Message: ' + str(deleteResponse.message))
print( 'Results: ' + str(deleteResponse.results))
print( '-----------------------------')

I am getting the following error even though it was deleted successfuly

>>> Delete the new Campaign
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/FuelSDK/rest.py", line 30, in __init__
    self.results = response.json()
  File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "delete_testing.py", line 63, in <module>
    deleteResponse = deleteCamp.delete()
  File "/usr/local/lib/python3.5/dist-packages/FuelSDK/rest.py", line 557, in delete
    obj = ET_DeleteRest(self.auth_stub, completeURL)
  File "/usr/local/lib/python3.5/dist-packages/FuelSDK/rest.py", line 385, in __init__
    obj = super(ET_DeleteRest, self).__init__(r, True)
  File "/usr/local/lib/python3.5/dist-packages/FuelSDK/rest.py", line 32, in __init__
    self.message = response.json()
  File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The following line is causing error as it might be unable to parse the response.
return self.scan_once(s, idx=_w(s, idx).end())

For verification, I ran the delete code again it shows the following error.

>>> Delete the new Campaign
Delete Status: False
Code: 400
Message: None
Results: {'error code': 10000, 'message': 'Campaign does not exist.', 'documentation': ''}

and there was no campaign with id= 361 listed in the campaign so it must have been deleted while executing the delete method even though it threw an error in that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant