Hello all,
I’m looking for a way to create or edit TTN applications using the API.
I’ve read the docs but it’s still somehow confusing to find a simple start
method to perform this (using PHP), so I’m looking for some examples
on how to start with this. Thanks a lot for any hints.
Ralf
As this is in the uncategorised section, which version of TTN?
Hello descartes,
that’s sort of a quick reply.
Of course I moved all my applications, devices and gateways
to TTN v3.In a first step, I would like to create or delete applications remotely
via my dashboard.
Kind regards
Ralf
Safari notifications and as a moderator I (briefly) read all the posts and we have an active thread on device creation and apart from general LoRaWAN experience, integrations is one of my areas of expertise (my superpower is reading the manual)
I’ll look at my game plan for samples, I know it’s not got exactly what you need right now but will give you some idea of what I’ve got in mind, but here’s what I’ve published so far:
So I’m happy to start on an TheThingsStack-API-Starters as I have a fair amount in Python already and PHP is just another imperative language that I code in reasonably frequently, so we can turn this and your device creation issue in to a proper piece of work.
My iMac now has a nice shiny new copy of macOS (Catalina) on it and most of the day to day apps are installed and I need a bit of break from paid-work so lets see if we can’t get this done in the next 24 hours.
OK descartes, thanks a lot.
Hello everyone,
I want to create an application in TTN V3 via HTTP Post API. I read the documentation and know, how to make an HTTP Post request to make a new application in TTN. But I am struggling to set up the JSON data that I have to send with my Post request.
Does anyone have a sample JSON data so that I can debug mine and find the error? Maybe someone knows any link where I can read and can correct me. Thank you so much.
Kind regards
Imran Khan
I’m assuming the excitement of getting devices working means you forgot about this thread you started a couple of days ago …
Good morning descartes,
Thank you so much, because of you my devices are working now. My apology for repeating the same post. Actually, this post was made by my colleague, and I didn’t know about that. I will have a look at the discussion.
Kind regards
Imran Khan
I will be very pleased to work with you to do something better for the TTN Community. I am basically an IoT & PHP Full Stack Developer and Python is already in my lerning list. I will have a look at your repository and will be in contact with you.
As standard, and as good practice - anywhere in the Inet!, we recommend you dont share user names and passwords… its trivial to set up a new account for aternate users. We have organizations and collaborators options to allow, well, collaboration & sharing and you can always copy a fellow user using thier @‘username’ tag so all aware of activity/avoid duplication and splitting of efforts…
The procedure to create an Application using HTTP Post request is given below.
I am using PHP so I first prepared an array as given below.
$appReg = [
'application' => [
'ids' => [
'application_id' => $this->appId
],
'name' => $this->appName,
'description' => $this->description
],
'field_mask' => [
'paths' => [
'ids.application_id',
'name',
'description'
]
]
];
I converted my array to JSON as given below using json_encode()
$app_registration = json_encode($appReg);
Post URL is as given
$url = ‘https://eu1.cloud.thethings.network/api/v3/users/my_user/applications’
and just made cURL Post as given below
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array($authorization, 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $app_registration);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);