0

How to get whole record/view per API?

Hello,

I got a problem with receiving records via API.

Table / data structure

  • Company (can have many Locations)
    • Company Name
  • Location (can have many Services)
    • Location address
    • Location phone number
  • Service
    • Type of service
    • Company Name
    • Location address
    • Location phone number

In my Service view (in Ninox) I added 'Company Name', 'Location address', 'Location  phone number' to have them all in this table / view (?) to get them in a single call.

API request that works, but spits out only IDs
https://api.ninox.com/v1/teams/xxx/databases/xxx/query?query=(select Service where chosen(N,8)

Result: ["N17", "N18", "N19", "N60"]

Well - since I can not figure out how to get the whole records with this call, I do a loop for each record:

https://api.ninox.com/v1/teams/xxx/databases/xxx/tables/N/records/N17
Result: Internal Server Error

WTF? Okay - without the N?

https://api.ninox.com/v1/teams/xxx/databases/xxx/tables/N/records/17
Result: the record, but without the extra fields I added (Company Name, Location address, Location phone number)

I hope here is someone that knows how I can modify my initial query to get all necessary data.

4 Antworten

null
    • UweG
    • vor 1 Jahr
    • Gemeldet - anzeigen

    Use the exec query. So, you can define in a global Ninox Function wich values should be return. You can also use the pagination to expand the return of the 100Record limit.

    • UweG
    • vor 1 Jahr
    • Gemeldet - anzeigen
    • UweG
    • vor 1 Jahr
    • Gemeldet - anzeigen

    Here is an example:
    Global Function in Ninox:
    function ListRecord() do
        let vTable := (select API_DataTable);
        let vRecords := for i in vTable do
                {
    Name: i.Name,
                    Zahl: i.Zahl,
                    Boolean: i.Boolean,
                    dynMultiChoice : text(i.dynMultiChoce),
                    functionField : i.functionField,
                   date: format(i.date, "MM-DD-YYYY")
                }
            end;
        vRecords
    end;

    You see, that you get back the value of a function-Field in the Record, which you never get with a simple GET-Request.

    Here the http-Request:
    let vUrl := "https://Test.ninoxdb.de/v1/teams/d3p8zzk6ytvee6eee/databases/c6s98n6rag10/exec?perPage=10000";
    let vHeader := {"Authorization":"Bearer API-KEY","Content-Type":"application/json"};
    let vBody := {"query":"ListRecord()"};
    do as server
    http("POST", vUrl, vHeader, vBody)
    end
    ------------------
    ?perPage=10000 means, you extend the the get back-limit of 100 Records.

    Here is the curl Form.
    You can test it here: https://reqbin.com/curl

    curl https://Test.ninoxdb.de/v1/teams/d3p8zzk6ytvee6eee/databases/c6s98n6rag10/exec?perPage=10000
    -X POST
    -H 'Authorization : Bearer API_Key'
    -H 'Content-Type : application/json'
    -d '{"query":"ListRecord()"}'

Content aside

  • vor 1 JahrZuletzt aktiv
  • 4Antworten
  • 357Ansichten
  • 2 Folge bereits