Search code examples
python-3.xpostpython-requestsformatfiddler

python how to fix wrong request


Iam sending request to log in into the web, but i logged manualy checked what server sended me back and tried to copy this json format and edit it. But with no success.

 logindata = {"p_json": {"salt": "37832371416286084378080214994328475118",
                        "pageItems": {"itemsToSubmit": [{"n": "P101_LINGUA_RILEVATA", "v": ""},
                                                        {"n": "P101_USERNAME", "v": "XXXXXXXXX"},
                                                        {"n": "P101_PASSWORD", "v": "YYYYYYYYY"},
                                                        {"n": "P101_LINGUA", "v": "it"}],
                                      "protected": "JipTylR4bB8lKI8I2VBSlQ",
                                      "rowVersion": ""}},
             "p_flow_id:": 112,
             "p_flow_step_id": 101,
             "p_instance": 14658069797106,
             "p_page_submission_id": 173195393854667729155471500057846249278,
             "p_request": "P101_LOGIN",
             "p_reload_on_submit": "A"}

Here you can see what i try to send, but if i compare this json with fiddler and post request which i do by logging to the website, this isn´t correct. This is how my json looks like in post request: enter image description here

and it should be in this format: enter image description here

Iam able to change salt, and other security params but why my Json in pic 1 is not same like the original post?

I tried to format variable login data with many ways but with no success to see in the fiddler proper format of the sended request


Solution

  • Solved, There is neccesary to iterate for all keys and for each key do json.dumps() to ensure that the strings will be sended in keys.