Skip to content

Conversation

rdhyee
Copy link

@rdhyee rdhyee commented Jul 11, 2017

I chose """ as the surrounding quotes because I'm not sure whether you will have ' or " in the dict_to_pretty_string(post_data_json).

@rdhyee
Copy link
Author

rdhyee commented Jul 11, 2017

@spulec Sorry that I didn't work through your tests before submitting this PR. Let me take a look.

@spulec
Copy link
Owner

spulec commented Jul 11, 2017

Python requests allows passing data as a dictionary. See here. Are you running into problems with this?

@rdhyee
Copy link
Author

rdhyee commented Jul 11, 2017

Yes, I'm having problems with using data as a dictionary. I'm using the latest version of requests (2.18.1). I find that if I switch data to json, then I have success.

Here's the form of something that doesn't work:

   data={
        "_ApplicationId": "xxxxxxxx",
        "_ClientVersion": "xxxxxxx",
        "_InstallationId": "xxxxxxx",
        "_JavaScriptKey": "xxxxxxxx",
        "_SessionToken": "xxxxxxxx",
        "_method": "GET",
        "where": {
            "group": {
                "__type": "xxxxxx",
                "className": "xxxxxxx",
                "objectId": "xxxxxxx"
            }
        }
    },

I find that replacing data with json

   json={
        "_ApplicationId": "xxxxxxxx",
        "_ClientVersion": "xxxxxxx",
        "_InstallationId": "xxxxxxx",
        "_JavaScriptKey": "xxxxxxxx",
        "_SessionToken": "xxxxxxxx",
        "_method": "GET",
        "where": {
            "group": {
                "__type": "xxxxxx",
                "className": "xxxxxxx",
                "objectId": "xxxxxxx"
            }
        }
    },

and turning data into a string works:

   data="""{
        "_ApplicationId": "xxxxxxxx",
        "_ClientVersion": "xxxxxxx",
        "_InstallationId": "xxxxxxx",
        "_JavaScriptKey": "xxxxxxxx",
        "_SessionToken": "xxxxxxxx",
        "_method": "GET",
        "where": {
            "group": {
                "__type": "xxxxxx",
                "className": "xxxxxxx",
                "objectId": "xxxxxxx"
            }
        }
    }""",

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.

2 participants