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

Supporting non-json REST endpoints #264

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Supporting non-json REST endpoints #264

wants to merge 4 commits into from

Conversation

nisseknudsen
Copy link

When entering a rest URL in the restful function, it automatically returns the parsed json response. For downloading files from Salesforce, e.g., ContentDocumentVersion, the response is of Content-Type: application/octet-stream (interestingly, the real value in the response header from Salesforce is application/octetstream, in contrast to their documentation).

The changed restful function now reads the Content-Type value and parses the json for Content-Type: application/json and returns an unparsed response for all other Content-Type values.

When querying ContentDocumentVersion, the response from Salesforce is a REST path which includes the /services/data/vXX.X/ prefix. To provide a fluent usage of simple-salesforce with other applications, the restful function now accepts the prefix, and removes it by using a regex.

@andscoop
Copy link
Collaborator

andscoop commented Feb 7, 2019

I would like to see some more feedback from the community before doing anything with this one. I'm concerned that we are now returning two types and that may break downstream code.

Personally i'm starting to lean towards having most of these API calls return the requests.response object by default and then adding a flag on Salesforce class to make a best effort to return json.

I would also need to see tests written for this before I'd be willing to merge.

@andscoop andscoop added Needs Tests Needs testing written before merge Open Community Review Issue or PR is specifically awaiting more feedback from the community Linting Errors Needs linting errors resolved before merge labels Feb 7, 2019
@@ -299,16 +302,16 @@ def restful(self, path, params=None, method='GET', **kwargs):
* method: HTTP request method, default GET
* other arguments supported by requests.request (e.g. json, timeout)
"""

url = self.base_url + path
base_regex = r'\/*services\/data\/v[0-9]{2}.[0-9]{1,}\/'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is something that you really should consider to merge since resources URIs include "services/data/vXX.X" in it, so if any tries to search any resource using the URI returned in a previous call it will not work as it now assumes resources URIs dont include the services/data/vXX.X part.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not opposed to merging this in just need to review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linting Errors Needs linting errors resolved before merge Needs Tests Needs testing written before merge Open Community Review Issue or PR is specifically awaiting more feedback from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants