TheRutubeify
TheRutubeify

Reputation: 666

python requests @ params

I try to using request.get with '@' in params, but in output I have '%40' How I can decode this dict?

Using Python3

import requests

payload = {'OPERATION-NAME': 'findItemsByProduct','productId.@type':'ReferenceID'}

req = requests.post(url, params=payload)

print(req.url)

The output is - 'url?productId.%40type=ReferenceID'

Upvotes: 0

Views: 373

Answers (1)

epinal
epinal

Reputation: 1465

Use "data" argument instead of params. You should also specify the header, in this case json and then convert the payload dict to json using json.dumps().

import requests
import json


payload = {'productId.@type':'ReferenceID'}

req = requests.post(url, headers={'Content-Type': 'application/JSON'}, data=json.dumps(payload))

print(req.url)

Upvotes: 1

Related Questions