Help required HTTP POST implementation

I made a few apps using MIT AI. Thanks to the team.
I want to create a new channel in my Thingspeak account.
They recommend the below explained in (Create new channel with HTTP POST - MATLAB - MathWorks India)

POST https://api.thingspeak.com/channels.json
api_key=XXXXXXXXXXXXXXXX
name=My New Channel

expected response is as below with a new channel created on thingspeaks.
{
"id": 4,
"name": "My New Channel",
"description": null,
"metadata": null,
"latitude": null,
"longitude": null,
"created_at": "2014-03-25T13:12:50-04:00",
"elevation": null,
"last_entry_id": null,
"ranking": 15,
"username": "iothans",
"tags": [],
"api_keys":
[
{
"api_key": "XXXXXXXXXXXXXXXX",
"write_flag": true
}
]
}
blocks

after launching the app channel is not created and the responses on the app is

you can not post a list, but try to post a string like aa=bb&cc=dd, or use a buildRequestData block

Also you forgot to set the request header

Content-Type
application/x-www-form-urlencoded

Taifun

1 Like

But buildRequestData is a call so do I post the URL first?

Here is an example App Inventor Tutorials and Examples: MySQL | Pura Vida Apps
Remove the Get method
EDIT: Add the Request header block

Use the Post method together with the BuildRequestData method as shown in the example
Taifun

Thank you Taifun and Kevinkun, I could create the channel successfully.
the blocks are as seen below. I still need your help in passing three more parameters.
name=My Channel (this is done with your help)
public_flag=true
field1=Stuff
field2=Things
field3=Data


:point_up_2: These are working blocks for channel creation.

I tried this


and this but no success. ( :point_down: creates a channel with the name " MyChannel1\nfield1=Stuff\nfield2=Things\nfield3=Data")

Please guide :pray:

use & not \n

The request header block needs a list of sublist, each of the sublists is a tag/value pair.. as it is working without being correct, you can omit that block

Also the BuildRequestData method needs a list of sublists, i.e.withoug the =

name
MyChannel1

field1
Stuff

field2
Things

field3
data

Taifun

Thank you Taifun and Kevinkun, I think my issues are addressed.
Below is the block I used for testing and it worked :slightly_smiling_face: :pray:

but your block is not correct for the RequestHeaders, it should be a list of list, as @Taifun mentioned in last post.
Did you got any error message?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

This is in continuation of the below post

The result of above was & it is working

But I tried to modify the data as below
Clipboard01

The system works but I get a message as

Please help to find the error.

A few days ago we found an error in the SpreadSheet component with the join block. I don't know if the join with Web has the same error.

https://community.appinventor.mit.edu/t/testers-wanted-google-sheets-component/49195/58

Check to put the data in an Intermediate Label.

fsdfdfds

header should be a list of list.
You need to add a 'make a list' block.

Tried the below blocks, same response with no success also the channel is not created.

You misunderstood..
The request header must be a list of lists, I.e. 2 make a list blocks....
See again

Taifun

Thanks Juan,
I tried as suggested by you.
But no change.

Dear Taifun,
if I change anything in request header the channel creation is not happing as per requirements.
We can only work with the PostText.

do you know the meaning of 'list of list'?

or set the header as a Dictionary.