How to get the response from HTTP Get Request

Hello All,

I am using frappe cloud and trying to implement a scenario using Server script where I use:
response =frappe.make_get_request(''+doc.field1,auth=None, headers = None)
to get a response from third party.

The response will be in JSON, now I dont know how to work with it, I want to parse it so that I can extract its data and save into my form fields.

For Example if the response is:

"apifield1": "No",
    "apifield2": "Yes"

and I want to save the value of apifield1 in my form’s field, then how to do it, please can someone help.



Create a server script with following code as DocType Event - Before Save:

response =frappe.make_get_request(''+doc.field1,auth=None, headers = None)

for i in response:
    doc.field1 = i.apifield1
    doc.field2 = i.apifield2 


Divyesh Mangroliya

Hi, thank you for your response, I see some progress after applying your input, the document atleast gets saved. But still, the fields are empty, checking the network logs, I find that the values are coming as null although they should not. Any particular way to write this part. I have written as below:

for i in response:
        doc.full_name = i.Rate_Name
        doc.mydata = i.Rate

I finally figured it out, for me the following works:

doc.full_name = response['Rate_Name']