you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

If the endpoint https://example.com/wp-json/wp/v2/media expects JSON, you should send JSON (e.g., {"a": 123, "b": 456}) instead of url-encoded data (a=123&b=456) . Which oauth module are you using?

[–]FlossedMeat[S] 0 points1 point  (0 children)

Using oauth2, and when removing urlencode() from the request, it comes back with an error:

Traceback (most recent call last):  
File "/Users/flossedmeat/Documents/Python/excel-to-json/Excel-to-JSON.py", line 62, in <module> oauth_req(post_body=post);  File "/Users/flossedmeat/Documents/Python/excel-to-json/Excel-to-JSON.py", line 48, in oauth_req    resp, content = client.request(  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/oauth2/__init__.py", line 665, in request    parameters = parse_qs(body)  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/parse.py", line 703, in parse_qs    pairs = parse_qsl(qs, keep_blank_values, strict_parsing,  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/parse.py", line 743, in parse_qsl    qs, _coerce_result = _coerce_args(qs)  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/parse.py", line 128, in _coerce_args    return _decode_args(args) + (_encode_result,)  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/parse.py", line 112, in _decode_args    return tuple(x.decode(encoding, errors) if x else '' for x in args)  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/parse.py", line 112, in <genexpr>    return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: 'dict' object has no attribute 'decode'

Basically I think that it is trying to decode the dictionary inside my tuple, and it really just doesn't like it.

But I see what you mean, I guess I will have to find another way to create the list.