Add Object Record

Options

Hi,

I want to add a new record using API. I have an object field called "Layanan" and inside it has an enum list with 3 values which are "BI-RTGS", "BI-Fast", and "Lalu lintas Giro". I tried to do it, but it returns the following error message. How should I do it?

Tagged:

Answers

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    I would first debug the api response itself and see if the parameter Layanan is 100% there. The other thing is to use "get" filter instead of dot notation, which allows you to assign a default value even if certain path is missing.

    But first and foremost I would start with you layanan object and check it step by step. I would be able to tell more if you can share the screenshot of the API response itself.

  • alya melati
    alya melati Member
    Options

    Hi @Pawel Magdanski,

    I debugged the transaction table using GET /transaction API (to query all record) and the "layanan" parameter is there (see image below)

    I also change the path in POST /transaction API (to add a new record), however, I don't know if the path I defined is correct (see image 2 below)

    I attempted to add a new record with this script :

    "user_id": 1, 

    "no_rekening": 123456, 

    "nominal": 50000, 

    "berita": null, 

    "layanan": [   2  ], 

    "status": "allowed"

    }

    and the API response is still like this :

    I thought that perhaps I write the scripts wrong, but I don't know how should I write it right

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    So first thing that I can see is that layanan is an input, I would first put it into variable. Second thing your path is transaction.layanan which does not seems right looking at the screenshot of the object you provided

    Try something like layanan.0 → get → Layanan → first

  • alya melati
    alya melati Member
    Options

    Okey, I tried to do this, but I still got the same error message. Could you please give me more instruction? @Pawel Magdanski

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    Hi,

    Well, first thing I can see is that your first layanan is a text, not a variable. Secondly your second layanan is not starting with capital letter.

    You need to be precise with those things, and the mistake of putting text instead of variable into field is one of the most common ones.