Create channel from Excel VBA | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Create channel from Excel VBA
No permission to create posts
April 11, 2019
4:47 am
Avatar
ecomiss
New Member
Members
Forum Posts: 2
Member Since:
April 11, 2019
sp_UserOfflineSmall Offline

Hello,
Il am trying to create a new channel from Excel VBA using REST API but it is not working. My user API Key is good and it is working from Postman. I have this error : error_auth_required.

Here is what I do in VBA :

Sub test()
Dim objHTTP As Object
Dim url As String, sampleBody As String
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
url = "https://api.thingspeak.com/channels.xml"
objHTTP.Open "POST", url, False
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
sampleBody = "{" & Chr(34) & "api_key" & Chr(34) & ":" & Chr(34) & "myUserAPIKey" & Chr(34) & ", " & Chr(34) & "name" & Chr(34) & ":" & Chr(34) & "apitest2" & Chr(34) & "}"
objHTTP.send sampleBody
End Sub

Please help on this...

Postman is the only way to create channel in ThingSpeak? I need Excel because I have to automate many processes including ThingSpeak and other Applications.

April 12, 2019
8:04 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 643
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Chr34 is double quotes. Perhaps Im not understanding the format you are trying for. Does your API request in postman have double quotes? Also where is the apitest2 parameter coming from? Perhaps you could print the body to the output to see what it looks like first. Is been a while since I've written in VBA, but the formatting seems odd. Perhaps try to find a working POST request in VBA and modify it to fit the ThingSpeak API.

April 14, 2019
4:05 am
Avatar
ecomiss
New Member
Members
Forum Posts: 2
Member Since:
April 11, 2019
sp_UserOfflineSmall Offline

Here is what I have for my body : "{"api_key":"myUserAPIKey", "name":"apitest2"}".
I tried with and without double quotes and I always have the same error : error_auth_required
I do not understand... 🙁

April 16, 2019
10:19 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 643
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Try it without a body, or send a blank body.
Make the url "/channles.xml?api_key=XXXXXXXXXXXXXXXX&name=apitest2"
or https://api.thingspeak.com/channles.xml?api_key=XXXXXXXXXXXXXXXX&name=apitest2

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
36 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

porosh2019, KellyBrise, sunainakhanna, flail, sathwik, samlewis02

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457