Deluge Error Code 1002 - "Resource does not exist."

Deluge Error Code 1002 - "Resource does not exist."

I am using the following script in a Custom Button on a Sales Return.

Basically, the function takes the information in the sales return (plus the arguments that are entered by the user when the button is pushed) and creates a return shipping label via the Easypost API. This part works perfectly.

I then want to take information returned and update custom fields in the Sales Return, which is not working and giving the error in the title (1002 - Resource does not exist).

  1. //Update Sales Retrun object with label info via API
  2. id = salesreturn.get("salesorder_id");
  3. pop_lab_data = invokeurl
  4. [
  5. url :"https://www.zohoapis.com/inventory/v1/salesreturns/" + id + "?organization_id=" + organization.get("organization_id")
  6. type :PUT
  7. parameters:dataMap.tostring()
  8. connection:"zom2"
  9. ];
  10. info pop_lab_data;
  11. //

It's not obvious if the resource in question is the Sales Return or one of the custom fields being updated. Neither of those seem to be true as far as I can tell.

Any thoughts on how to solve this problem?

Here is the output after running the function (the info of the map data + error code)

{"custom_fields":[{"api_name":"cf_tracking","value":"1ZY777560323320163"},{"api_name":"cf_label_cost","value":"10.08"},{"api_name":"cf_label_link","value":"https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20251107/e860fa67931f3e4566911e57ac0f72076f.pdf"}]}

{"code":1002,"message":"Resource does not exist."}