Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exception thrown when salesforce returns 204 #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DovAmir
Copy link

@DovAmir DovAmir commented Jun 19, 2018

exception thrown when salesforce returns 204.
this happens when doing PATCH request in record field because reponse is empty string and cant be
serialized
result.json(object_pairs_hook=OrderedDict)

exception thrown when salesforce returns 204.
this happens when doing PATCH request in record field because reponse is empty string and cant be 
serialized
result.json(object_pairs_hook=OrderedDict)
@metadaddy
Copy link

metadaddy commented Nov 22, 2019

I see this same problem (exception on 204 response). My solution is very similar:

    # Generic Rest Function
    def restful(self, path, params=None, method='GET', **kwargs):
        """Allows you to make a direct REST call if you know the path

        Arguments:

        * path: The path of the request
            Example: sobjects/User/ABC123/password'
        * params: dict of parameters to pass to the path
        * method: HTTP request method, default GET
        * other arguments supported by requests.request (e.g. json, timeout)
        """

        url = self.base_url + path
        result = self._call_salesforce(method, url, name=path, params=params,
                                       **kwargs)
        if len(result.content) > 0:
            json_result = result.json(object_pairs_hook=OrderedDict)
        else:
            return None

        return json_result

@thommor Either way, this needs to be integrated as the current behavior breaks DELETE and PATCH requests.

@metadaddy metadaddy mentioned this pull request Nov 23, 2019
@thommor
Copy link
Collaborator

thommor commented Nov 23, 2019

Thanks @metadaddy. Let me work out why the Travis builds are failing and I’ll merge this in ASAP.

@metadaddy
Copy link

@thommor The Travis failures look like pylint issues to me. Not sure what it's complaining about.

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

Successfully merging this pull request may close these issues.

None yet

3 participants