What documentation is that? We might want to fix that.
True. The API expects a POST body (payload) to hold bare JSON, but a <form method='post'> will create a body that defines parameters with values. So that’s a dead end.
(You’re not specifying enctype, which then defaults toapplication/x-www-form-urlencoded. But the other option, multipart/form-data as used for file uploads, won’t help either. Also, the API probably expects Content-Type: application/json or similar.)
However, using JavaScript won’t get you any further either, as then you’ll run into the console showing something like the following:
Access to XMLHttpRequest at … from origin … has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Hello Arjan, so not as easy as I thought. I am an oldfashion HTML hacker and thought I could make it easy with a HTML form. The handling (CGI/PERL) of the uplink data was no problem. Because I do not use JS in the page, I also get no CORS error. But I am going to look (after a lot of reading) for an intermediate server in PERL to solf the problem. Thanks and regards…
enctype='application/json' is not a valid option for the browser, so should be rejected or be replaced by the default. (I’m quite sure it is valid for TTN; it’s just that <form method='post'> cannot use it.)
If there’s any error then that should be shown in your browser’s JavaScript console or network tab. There’s no historical logs you can access on TTN.
Ah, my bad: actually, the chance is zero, as <form enctype="plain/text" method="post"> would still post parameter names (as given in <input name="whatever">) along with their values, not only the value(s).
That’s the result of the browser trying to find an icon after navigating to the action URL while posting the data. You’ll want to see what the response of the POST to that action URL is. Make sure to use something like “Persist logs” or “Preserve logs” in your browser’s network tab, to see the result of that very URL.
I chose the path of Arjan ( intermediate server ), not Postman or curl but PERL/LWP…
#!/usr/bin/perl -w
use strict;
use warnings;
# Create a user agent object
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1");
# Create a request
my $req = HTTP::Request->new(POST => 'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/5935br27environment/environment?key=ttn-account-v2.xxxxxxxxxxxxx');
$req->content_type('application/json');
$req->authorization_basic("admin", "secret");
$req->content('{"dev_id": "5935br27node000","port": 1,"confirmed": false,"payload_raw": "AQIDBA=="}');
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
} else {
print $res->status_line, "n";
}
it works.
Now the finishing touch. thank you all and regards…