OpenFn / primero-progres

Interoperability solution for UNICEF <> UNHCR interagency referrals between Primero and Progres v4 systems.
https://openfn.github.io/primero-progres/
0 stars 2 forks source link

Flow1-1. Send Referrals to Primero fails with `422 Invalid JSON` error #25

Closed aleksa-krolls closed 3 years ago

aleksa-krolls commented 3 years ago

Describe the bug

See run here: https://www.openfn.org/projects/p5am6e/runs/r89y49pz

Error: Server responded with:  
{
  "statusCode": 422,
  "body": {
    "errors": [
      {
        "status": 422,
        "resource": "/api/v2/cases/c8e64abf-6ee1-41f9-9fa2-d3ee14de8117",
        "detail": [
          "/progres_interventionnumber",
          "/remote",
          "/assigned_user_names",
          "/created_by"
        ],
        "message": "Invalid Record JSON"
      }
    ]
  },

To Reproduce

Feel free to re-run on prod. Remember Primero recently updated API so we have to send content-type: application/json in the HTTP request header. Wondering if that is related to this or if something else is going on?

expression.js

https://github.com/OpenFn/primero-progres/blob/master/jobs/1.upsertExtracts.js

state.json

See LP for Primero Dadaab (open_function API-only user)

lakhassane commented 3 years ago

@aleksa-krolls I doubled check here and it seems like (also in the logs) we have bad data in the json we update. See these fields here:

"detail": [
          "/progres_interventionnumber",
          "/remote",
          "/assigned_user_names",
          "/created_by"
        ],

If you check thoses fields in the message are you able to say if they are correct? I made a test by commenting them out of the job and had a green check locally.

aleksa-krolls commented 3 years ago

Thanks @lakhassane! I will revisit the mappings.