Server error upon adding new device leads to duplicate devices - xively

TL;DR -
I have erroneously created a load of duplicate devices in Xively. How do I delete them, using only my browser? Or do I need to write a Perl script?
I have just opened a new Xively personal account, and was running through the Test Drive.
Upon step 2
I added a new device
Upon clicking Add Device, I received a server error
After repeated attempts (clicking on the browser's back button and trying again), I clicked on the Develop link at the top of the page, only to be shown multiple duplicate devices:
If I click on a device, to open its Workbench, I get another server error (note that the URL is different from the first):
Is there currently a server error - nothing is mentioned about the server being down in the Twitter feed? How do I delete the duplicate devices, or edit them? Is there a way of managing them? I don't appear to be able to find a link to contact the support desk. Is there actually a support desk available?
Is my account now "ruined"? Should I give it up as a bad job and open a new account?
P.S. When I was adding the devices I was running through a VPN (TunnelBlick on OS X), but surely this should not have caused the issue..?
I have tried following the information from Delete a Device:
Method DELETE
Base URL https://api.xively.com
API Endpoint /v2/products/PRODUCT_ID/devices/SERIAL_NUMBER
However I do not know what the PRODUCT_ID is, and I am only guessing that the SERIAL_NUMBER is the code at the end of the device URL?
Click on one of the duplicate devices to obtain the device URL (even though it still leads to the server error page): https://personal.xively.com/develop/sfStgqRmlqymGIFeHleB
Forming the delete URL:
https://api.xively.com/v2/products/PRODUCT_ID/devices/sfStgqRmlqymGIFeHleB
After logging in to confirm the delete action, I get the message
{"title":"Not found","errors":"Couldn't find Product with product_id = PRODUCT_ID"}
How do I discover the PRODUCT_ID?
So, from List All Products:
Method GET
Base URL https://api.xively.com
API Endpoint /v2/products
I used the URL:
https://api.xively.com/v2/products
and I get a list of all of my Products, which are actually of the duplicate devices, and a series of different PRODUCT_IDs. (It seems a bit odd that the devices have PRODUCT_IDs and not device SERIAL_NUMBERs):
{"totalResults":7,"products":[{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"sfStgqRmlqymGIFeHleB","secret":"41aad0ab3fec62efd94fc7d54f77a911f232522d","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"luXVnI1ymGHW4SonH-37","secret":"e923aad16dce33e6635e7a8620243110ba93e9cc","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"4NV5BvCmx54q84AcVCLB","secret":"13e624cececcecf9af6e558874cdf78e65049fe8","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"l8S8kBZWWG_s1YRrytwW","secret":"5a476bc550055d8ab7dc7c72ceb0433fd39e451f","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"jWWRuW_JhkXqKUA0F769","secret":"b3a5d78b51dca5d3ef56268141e7c25c8d00a61a","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"3nXDH0DV6z3_y5cr47qA","secret":"7793d8607194fec4a7e85c0091df93642fc68069","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"TWF2T_IXpS7sDZxSlc2f","secret":"9f03403167b467ec7fec295c87c6260b3a4074cc","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"}]}
Following on from that, from Delete a Product:
Method DELETE
Base URL https://api.xively.com
API Endpoint /v2/products/PRODUCT_ID
I create the URL
https://api.xively.com/v2/products/TWF2T_IXpS7sDZxSlc2f
Where TWF2T_IXpS7sDZxSlc2f is the last PRODUCT_ID in the product list generated above. However, this just returns the data for that PRODUCT_ID:
{"product":{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"TWF2T_IXpS7sDZxSlc2f","secret":"9f03403167b467ec7fec295c87c6260b3a4074cc","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"}}
The issue is now that how do I perform a DELETE method, through my browser, as the URL is just a GET and is basically performing a Read a Product instead of a Delete?

The answer is to, recursively for each PRODUCT_ID, use curl
curl -X DELETE 'api.xively.com/v2/products/3nXDH0DV6z3_y5cr47qA' -u 'username:password'

Related

Unable to get the edge access token

I have created a new mimik developer account, and I was trying get the edge access token using the command "mimik-edge-cli account get-edge-access-token -t <--id token-->". But I am getting an "Error" as response.
I have tried with my previous account and in that case i am able to get the access token as shown below. Same issue happened for raspberrypi too.
why it is not able to get the access token while using a new account?
Please make sure to copy the ID Token from developer portal correctly, In most cases there might be a hidden character copied. Maybe just try copying the text by highlighting with mouse from first character to the last. Do NOT use the copy to clipboard button. Also please make sure that the edgeEngine on the PI is not associated already by checking with:
mimik-edge-cli account get-me
When you input command above, if you see an ID for value "accountId:" then your PI is already associated an CANNOT be associated again. You have to un-associate first and then associate with the new ID token from new account/project. You can verify that un-association is successful when above command shows empty value for "accountId:"
FOR FUTURE REFERENCE:
Please only tag questions with edgeSDK if it is related to FreeRTOS platform. For all other platforms, please use tag edgeEngine

Problem using ArduinoHTTPClient sending GET requests with ESP32

Board : ESP32 T-Call SIM800L
Code Functioning
Collect Data from phone -> Put Into URL -> Send to Server
CollectQualitativeData() -> AppendQueryParameters() -> http.get(resource)
My code allows me to enter 4 different strings in my android app which my ESP32 receives via bluetooth and stores as an array of char arrays QualArray[4][30] (eg. {"string1","string2"....) . It then adds these strings in the URL query parameters for which I send data to my google sheets web app with a GET request (I know i'm posting data but the get request is what is used for the google apps script when posting data).
Problem
The code works when I pre-define the URL to be sent, although the issue seems to be that adding the strings obtained from the android app to the URL returns an HTTP response of -3 and doesn't upload to the google sheets server. This confuses me as the strings are stored okay because I print them out and they are correct, and then adding them to the URL and printing the URL it looks correct (and identical to the pre-defined URL that works) but for some reason it doesn't work. I thought it could be memory related so I pre-defined all the char arrays with set buffers but still didn't work
Code
https://github.com/Conwon99/4th-Year-Project/blob/main/ESP32_HTTP_REQUEST
The functions to look at are CollectQualitativeData() which is called in setup and AppendQueryParameters() which is called in the loop, then http.get(resource) is called afterwards in the loop which makes the GET request.

Pulling only Registration Contact information on Asterisk

I am not using real-time asterisk , But still astdb.sqlite3 contains entries of online peers with Reg.Contact information in SIP/registry/peer. key . I would like to store contact information of all peers as they come online in a separate persistent database. I need this for sending push notifications by fetching deviceID etc information in registration contact .
I tried to pull this information from astdb.sqlite3 but the entries are clearing off as soon as devices go offline .Though I am able to fetch the information with "sip show peer XXXX" in asterisk CLI , It is overburdened to fetch every time like this . Instead I want to save only Regcontact information for all the devices in a database ( without realtime) as the devices come online. The other way I tried to pull the information is using AMI event listener. But with AMI I don't see complete information like contact information It displays only below information
Event: PeerStatus
Privilege: system,all
SequenceNumber: 75
File: manager.c
Line: 1856
Func: manager_default_msg_cb
ChannelType: SIP
Peer: SIP/2030
PeerStatus: Reachable
Can someone suggest a better way to push Only Regcontact information to a database as the devices come online .
There are no mechanism like that in asterisk.
You can use kamailio or write patch similar to this one https://reviewboard.asterisk.org/r/4490/
It sounds like you have dynamic IPs for your endpoints, and you want a way to update a separate DB as soon as a device registers with an IP/port pair.
If you enable the security log, you will see all auth events, including the "SuccessfulAuth" event, which includes the RemoteAddress of the endpoint (including port and protocol).
Here is an example line:
[Jul 21 19:53:45] SECURITY[1342] res_security_log.c: SecurityEvent="SuccessfulAuth",EventTV="2020-07-21T19:53:45.182+0000",Severity="Informational",Service="SIP",EventVersion="1",AccountID="102",SessionID="0x7f41040132c0",LocalAddress="IPV4/UDP/10.0.0.200/5060",RemoteAddress="IPV4/UDP/10.0.0.75/5062",UsingPassword="1"
If all you're looking for is AccountID="102" and RemoteAddress="IPV4/UDP/10.0.0.75/5062", a very fast/cheap way to get it is to enable the security log, and use a script to tail it and update your DB as soon as the event occurs. I like to keep the security log on anyways for utilities like fail2ban. Just make sure your script is able to reopen the file each time it is rotated.
Edit:
By default the log is in /var/log/asterisk. To enable it, edit /etc/asterisk/logger.conf and un-comment (or create) the line under [logfiles] that says security => security.

Firebase Hosting from freenom (dot.tk)

I would like to host my webapp on Firebase, since I'm using their services and functionalities since a long time (before Firebase was inside Google and since its static hosting service was named Divshot... ).
But I've got a demo domain from Freenom (.tk domain) and I was wondering how to connect this with firebase:
I can set only this paramater relative to TXT record:
dns management
so where should I define the parameters needed
google-site-verification=...
?
Thank You to all!
PS: I've already seen
Firebase hosting custom domain error
and related
firebase-talk Dqmz9Iuio54
and
and the question: how-can-i-verify-my-custom-domain-using-domains-google-com/39020649#39020649
but none of them seems to respond to my problem...
PS: I've come here from firebase support page where StackOverflow is the first choice.
Thank you!
Leave the "Name" field blank and fill "Target" with the google-site-verification=... value. Once you've done so, things should go through. One way to check is to run:
dig yourdomain.tk TXT
If you've done it correctly, you should receive back the google-site-verification=... value. It may take some time to propagate before it starts showing up.
DNS registrar / records host: delete TXT records pointing to
firebase.
firebase console: delete the custom domain.
firebase console: add custom domain.
copy the two TXT records from firebase to DNS host
DNS record host should include two entries with one yourdomain.tk and www.yourdomain.tk
Once the yourdomain.tk is added it'll show as empty and other entry will be shown as www.
The copy the two given A records to Freenom DNS records.
There will be 4 A records two for yourdomain.tk and two for www.yourdomain.tk.
Wait 24-48 hours to see if the changes work.
If it doesn't work, contact firebase support from the console; be sure to take screen shots of the DNS records and the firebase console. These will help the firebase support team to troubleshoot the problem.
Mean while you can check for the dns propagation by using below tutorial
The Firebase Hosting servers run what is essentially this command for verifying the TXT records for your domain:
dig -t txt +noall +answer yourdomain.tk
If you immediately run this command right now, you might not get results. If the Firebase servers are seeing the same in their DNS query, they will not be able to continue.
That means that either you didn't save/apply your changes yet, or they haven't propagated everywhere yet. The longer it takes for the changes to show up, the more likely it becomes that you still need to take some action at your DNS provider

Excel VBA - Web Server Authentication popup

I am trying to query into my spreadsheet a web relay device (ControlByWeb X310)X310 basically a IoT device. It has a built-in web servver and when I manually browse its URL for the first time it pops up with a web server login page (not a browser HTML window):
I've recorded a macro of adding this log data via an Excel insert "from Web" data connection. It basically uses recorded the following VBA:
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://111.111.111.111:8080/log.txt", Destination:=Range("$A$1"))....
Within the last item end With statement ".Refresh BackgroundQuery:=False" takes a while to do it's thing but returns nothing. If I've previously manually logged into the web page via my edge browser and authenticated access, then this command returns exactly what I need. I have thousands of these devices sitting on the internet that I need to collect data from so a script that will loop through each would be very practical.
Is there a command or syntax for the QueryTables object that can pass a user id and password to the login pop-up? Something like:
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://111.111.111.111:8080/log.txt", ID:="name", PWD:="password"
... does not work.
I've searched high and low and found a lot of info on login by scraping HTML but the pop-up I get is being service up by the web server authentication. Any help would be appreciated.

Resources