You need to sign in to do that
Don't have an account?
Yogesh Biyani
Convert python to Json
How do I convert the following python code into json body to be sent with the HTTP request?
TIA
TIA
params1 = { 'e': '{"event_type":"Launched Application","filters":[{"subprop_type":"user","subprop_key":"gp:app_name","subprop_op":"is","subprop_value":["desktop"]}, \ {"subprop_type":"user","subprop_key":"gp:sku","subprop_op":"contains","subprop_value":["SPEC"]}]}', 'm': 'uniques', 'start': '20190101', 'end': '20200131', 'i':'30' }
Convert python to Json:
Python to JSON (Encoding)
JSON Library of Python performs following translation of Python objects into JSON objects by default
Converting Python data to JSON is called an Encoding operation. Encoding is done with the help of JSON library method – dumps()
dumps() method converts dictionary object of python into JSON string data format.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Here is your JSON response
{
"e": "{\"event_type\":\"Launched Application\",\"filters\":[{\"subprop_type\":\"user\",\"subprop_key\":\"gp:app_name\",\"subprop_op\":\"is\",\"subprop_value\":[\"desktop\"]}, {\"subprop_type\":\"user\",\"subprop_key\":\"gp:sku\",\"subprop_op\":\"contains\",\"subprop_value\":[\"SPEC\"]}]}",
"end": "20200131",
"i": "30",
"m": "uniques",
"start": "20190101"
}
To know more please go through the below link:
https://www.guru99.com/python-json.html
Thanks and Regards,
Sachin Arora
www.sachinsf.com
Thanks for the reply. I tried to pass the JSON to httprequest but I get 405: Method not allowed message. Any suggestions.
Yogesh
Corresponding apex code
I get HTTP 405: Method Not Allowed
HTTP 405: Method Not Allowed:
The 405 Method Not Allowed is an HTTP response status code indicating that the specified request HTTP method was received and recognized by the server, but the server has rejected that particular method for the requested resource.
A 405 code response confirms that the requested resource is valid and exists, but the client has used an unacceptable HTTP method during the request.
To fix the problem go through the below link.
https://airbrake.io/blog/http-errors/405-method-not-allowed
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Sachin Arora
www.sachinsf.com