1

OPENAPI

I'm trying to write the openapi-api code to import company data from the VAT number. I can't figure out how to tell which value to put in which field. I don't understand anything about API but I'm trying and I want to learn. In this example I would like to import the "toponimo" from the api result and insert it into the "topo" field in Ninox. What am I doing wrong?

 

do as server
    let url := "https://imprese.openapi.it/advance/" + 'Partita Iva';
    let APIKey := "Bearer API-NUMBER";
    let response := http("GET", url, {
            Authorization: APIKey,
            'content-type': "application/json"
        }, {
            fields: {
                topo: data.toponimo
            }
end

 

The result api from where I need to get the data to my fields in Ninox, should give the data like below:

{
  "data": {
    "cf": "12485671007",
    "denominazione": "OPENAPI S.R.L.",
    "piva": "12485671007",
    "toponimo": "VIALE",
    "via": "F TOMMASO MARINETTI",
    "civico": "221",
    "indirizzo": "VIALE F TOMMASO MARINETTI 221",
    "comune": "ROMA",
    "frazione": null,
    "provincia": "RM",
    "stato_attivita": "ATTIVA",
    "timestamp": 1622452306,
    "timestamp_creation": 1622452306,
    "timestamp_last_update": 1622452306,
    "dettaglio": {
      "rea": "1378273",
      "cciaa": "RM",
      "pec": "openapi@legalmail.it",
      "codice_natura_giuridica": "SR",
      "descrizione_ateco": "Produzione di software non connesso all'edizione",
      "codice_ateco": "6201",
      "data_inizio_attivita": "2013-10-20",
      "bilanci": {
        "2017": {
          "data_chiusura_bilancio": "2017-12-31",
          "fatturato": 1120176,
          "utile": 2928
        },
        "2018": {
          "data_chiusura_bilancio": "2018-12-31",
          "fatturato": 1325358,
          "utile": 826
        },
        "2019": {
          "data_chiusura_bilancio": "2019-12-31",
          "fatturato": 1799587,
          "utile": 11309,
          "dipendenti": 14,
          "capitale_sociale": 10000
        }
      },
      "gruppo_iva": {
        "partecipazione": false,
        "piva_capogruppo": false,
        "anagrafica_ok": true
      },
      "cessata": false,
      "soci": [
        {
          "denominazione": "OPEN HOLDING S.R.L.",
          "nome": null,
          "cognome": null,
          "cf_socio": "16935371001",
          "quota": 100
        }
      ]
    },
    "cap": "00143",
    "codice_destinatario": "MJ1OYNU",
    "id": "60b4f9c914e27c27d12a9d67",
    "gps": {
      "coordinates": [
        12.47843,
        41.8071
      ]
    },
    "data_iscrizione": "2013-07-19"
  },
  "success": true,
  "message": "",
  "error": null
} (empty)

 

Here the link to the reference-page of the API

https://developers.openapi.it/categories/business_information/imprese#/Company%20Information/get_advance__piva_cf_or_id_

5 replies

null
    • thomas.4
    • 11 mths ago
    • Reported - view

    Can someone help me please? 😓

    • Ninox partner
    • RoSoft_Steven.1
    • 11 mths ago
    • Reported - view

    Did u try the url with postman? Did you get results? 
    you can also test the result by adding codeline: alert(text(result))

    Sorry, I can't test now on my ipad because of vacation trip. Tip: try your question also in the German forum...

      • thomas.4
      • 11 mths ago
      • Reported - view

       Thank for your reply. I didn't tried with postman but I've tried with the alert and I get: Request has failed error. Now I've posted the question also in the German forum. Thank you

      • thomas.4
      • 11 mths ago
      • Reported - view

       Now I've tried with this:

      let auth := {
              Authorization: "Bearer TOKEN-NR",
              'Content-Type': "application/json",
              'API-NUMBER': "API_NUMBER",
              expire: "DATE-TIME",
              scopes: "GET:imprese.openapi.it/advance"
          };
      let myURL := "https://imprese.openapi.it/advance/" + 'Partita Iva';
      let response := do as server
              http("GET", myURL, {
                  headers: auth
              })
          end;
      API_Response := text(response) (empty)

      and the result is:

      {"result":{"success":false,"message":"Missing token","error":125.18,"data":null,"trace":"WyJjbGFzcy5BdldzLnBocEAxNTkiLCJpbmRleC5waHBAMTM4OSJd"}}
      

      Is it possible that I have to do something in the openapi.com to activate the token?

    • thomas.4
    • 11 mths ago
    • Reported - view

    I've get to the final solution: 

    let auth := {
            Authorization: "Bearer TOKEN-NR",
            'Content-Type': "application/json",
            'API-NUMBER': "API-NR",
               };
    let piva := 'Partita Iva';
    let myURL := "https://imprese.openapi.it/advance/" + piva;
    let response := do as server
            let response := do as server
                    http("GET", myURL, auth, {})
                end;
            API_Response := text(response);
            'Company Name' := text(response.result.data.denominazione);
            topo := text(response.result.data.toponimo)
        end; (empty)

    Thanks for your help 😉

Content aside

  • Status Answered
  • 1 Likes
  • 11 mths agoLast active
  • 5Replies
  • 185Views
  • 3 Following