0

Ninox HTTP Calls syntax

What is the right syntax?

In documentation (https://ninoxdb.de/en/manual/api/http-calls) its mentionned :

1. http(method, url)
2. http(method, url, body)
3. http(method, url, headers, body)

for then 3. syntax i think its worng. I think http(method, url, body, header) is the right syntax. Because in documentation section POST its show the sample :

A POST request
let response := http("POST", "http://mytestservice.com/path", {
    hello: "World",
    'special character property': 1234
}, {
    Authorization: "Bearer API-Key",
    'Content-Type': "application/json"
});
if response.error then
alert(text(response.error))
else
alert(text(response.result))
end

 

And we can see that the header parameter is on fourth position and not in third like in documentation.

And the authorization and conent-type usually go into the header.

I'm right?

17 replies

null
    • Mconneen
    • 5 yrs ago
    • Reported - view

    @Robert.. I agree with what you are seeing.   Here is a post to the record url to return a single record based on a field match.   That said, this should return TWO records as I have two records in the table that match the critieria .. Looks like it is only returning the first.. I am still investigating. 

    recordURL

    • Sean
    • 5 yrs ago
    • Reported - view

    @Mconneen, I don’t have any experience with this, but if it is returning more than one record it would stand to reason that you would need access the different items like you would an array using item().

    • Mconneen
    • 5 yrs ago
    • Reported - view

    @Sean.. Well.. Sort of.  Here is what the json response looks like. 

    jsonResponse

    I was just dumping the complete json response into a text field to see what I got.    The following code gets only the Action field from the json response:

    code

    Ninox takes care of casting the json response to a record .. and then I can access the desired named attributes / fields.   So, for me.. the specific issue is that /record appears to be designed to return the first match.. even though my selection criteria may return multiples. 

    There are couple of different REST API / JSON samples in the Webinar...  I am using 36_Document_Database_Structure.. and yes.. that is the one that had the header wrong.... but it still works.  :) 

    • Sean
    • 5 yrs ago
    • Reported - view

    I think I follow... Did you try item(json, 1) or some other index?

    • Sean
    • 5 yrs ago
    • Reported - view

    Per the documentation... "The response consists of an array of records. Each record has the following common attributes:"

     

    I would try the following to get the string representing the second record...

     

    let json := response.result;

    let jsonItem := item(json, 1);

    'json Records' := jsonItem.fields.Action

    • Sean
    • 5 yrs ago
    • Reported - view

    I see what you're saying now. I tried it with item() and it comes up blank. The documentation does say Lookup  a single Record so I guess it finds the first record that matches the criteria and that's all you get if you are going use that request.

    • Mconneen
    • 5 yrs ago
    • Reported - view

    @Sean.. Right.. I am not sure if I misse a reply from the support email.. I asked if Records accepted a POST with filter.  Ideally, I would like the filter to occur at the query level.. not within a for loop. :( 

    • Sean
    • 5 yrs ago
    • Reported - view

    @Mconneen, yeah I spent most of my evening just trying to get the script working. One of my unanswered questions before I had to turn my brain off was how do you get more than one record without dumping the whole table. It’s bizarre that they would let you query the table, but limit the result set to one record.

    • Mconneen
    • 5 yrs ago
    • Reported - view

    @Sean.. Yup.. That is why I think I am doing something wrong.. We shall see. 

    • Mconneen
    • 5 yrs ago
    • Reported - view

    @Sean.. I guess I never emailed support.. so I did a bit ago... and got this reply.. 

    "A multiple response from Ninox via the REST/API is not possible at the moment, but the work on it is in progress and we will release that feature in the first half of this year.
    Thank you for your patience."

    • Sean
    • 5 yrs ago
    • Reported - view

    @Mconneen, Thanks for the update. I would think that the main reason for implementing REST/API is to use Ninox as a back end server. If that's the case, leaving out a fundamental function like a query that would return multiple records is unusual to say the least. Am I wrong? 

    • Mconneen
    • 5 yrs ago
    • Reported - view

    @Sean.. I have been kicking the Ninox tires for a bit now.. I have developed some applications that I use such as.. a slant on David Allen's "Getting Things Done" methodology... I call it Getting Sh** Done (GSD) .. LOL.. simple tasks and kanban cards..  I also developed an application that tracks all my Statements Of Work (SOWs) and provides a 30 / 60 / 90 view..  and of course.. my first and favorite application.. "Bingo" that is in the Webniar Team..  and I did a pro-bono application for a great charity in Africa that manages orphan healthcare .. funded by some great folks in Great Britian.... 

    I am still coming to grips with the "patterns" used .. Not being able to trap certain events... etc.... Yes.. it would have been nice to have the ability to filter to a set of records as opposed to having to filter in the for loop.. :) 

    That said.. The Ninox Support team as been AWESOME at returning email queries.. following up on the forum.. etc..  

    Bingo anyone?  LOL

    Bingo

    • Sean
    • 5 yrs ago
    • Reported - view

    @Mconneen, when you say you filter in the for loop, are you downloading all the records from the cloud to your computer and then filter them client side? My understanding at this point is you either get all the records or just one record from the server.

    • CISOFT_Sarl
    • 5 yrs ago
    • Reported - view

    Hi,
    I am very interested in your GTD application and the SOW. Could you show what they look like?
    Thank you in advance.

    • Mconneen
    • 5 yrs ago
    • Reported - view

    Here is the data model for the SOW application.    A SOW may have 0 or more amendments.  I cheated and always have at least one amendment.. the base SOW. ;)   On the Amendment .. I define roles (from the rate card) and assign resources.  I calculate the estimated number of billable days.. and multiply that out by pace (hours per week) and rate card rate. 

    sowDataModel

    And the basic data capture screen. 

    sowMain

    • Mconneen
    • 5 yrs ago
    • Reported - view

    I am actually in the middle of refactoring my GSD.... My first attempt was built off the Project Template.  

    I built a filtered table view for important projects.. and then a kanban view from that filtered table view. 

    kanban_01

    • CISOFT_Sarl
    • 5 yrs ago
    • Reported - view

    Thank you for your sharing Mconnen.

    Have a nice day ;)

Content aside

  • 5 yrs agoLast active
  • 17Replies
  • 6423Views