I have no access to backend of the ERPNext. I am subscribed to the $10/m plan. I have been using server/client scripts to add several features as I need.
My question today is regarding the Response object I recieve when I make the following get call (from server script of a doctype) to a service outside of frappe.
Now, doc.raw_response is a JSON fieldtype, and raw_text is Text.
Using the above, I get an empty dictionary (just → {}) in both the fields, while it should give me this → {“ABC.XYZ”:[{"Vendor No.: ":“XYZ”,"Start Date: ":“03/14/23”,"End Date: ":“03/15/23”,“Error”:“No materials”}]}
I get the correct response if I use Postman or even a local python script. Appreciate if someone could help resolve this, or provide a reference to make this work.
Firstly, I appreciate the efforts you are taking to help me solve this. I wanted to provide a detailed situation regarding my current challenge.
I have tested my client’s URL using Postman and a simple Python script utilizing the request library (outside erpnext). Both of these methods can successfully receive the JSON response. Here is an example response I received from both:
However, when attempting to run the same script through the erpnext server scripts, the response I receive is only an empty object {}.
I have double-checked my URLs and parameters several times, and they are identical to the ones I used in Postman and the Python script.
Furthermore, I tested using a dummy server to respond to the server script, and it worked flawlessly. Therefore, I am confident that the server script also functions correctly.
So the server script particularly doesn’t want to work for my clients url… haha. Are there any other methods I could achieve the result, like through client scripts or using other intermidiate platform?
The Client script above does not work for me. It says syntax error while loading the document. And it also doesnot show where that error is. I tried all possible syntax corrections, I think “fetch” is not the correct command for outside calls. Did it work for you @ayah ?
@ayah,
After implementing the same code to the same doctype, I encountered an error while attempting to start a new PO, which is depicted in the attached screenshot.
However, when saving the PO, the document is saved correctly, and the console does not log anything.
I am uncertain whether the script you provided is being executed at all. Could you please review my implementation and advise if there is an issue that needs to be addressed?