Post message to a channel using a simple one-line command!
Hi Everybody!This post is all about posting a message in a Channel using cURL, Wget and PowerShell. cURL is a light-weight, command interface used to transfer data to a server. The steps are pretty easy!
The three most important points here are
- Generating an Auth token
- Get your Channel Unique Name
- Form your message as a JSON structure
Generating an Auth token
To use the 'Messaging API' you'll need Cliq's authentication token from Zoho Accounts. Generate an auth token by hitting the below-given URL in your browser.
Send message to a channel by using the Channel Unique Name
How to get a Channel's Unique Name?
- Hover over any channel name from Cliq's left pane.
- This'll open the channel's preview. Select the 'More info' icon in the channel preview.
- You'll find the Channel Unique Name highlighted in the API Endpoint URL of the channel.
Your message structure in JSON
A simple message needs to be defined as a key-value pair in JSON. The 'text' will contain the message, which you'd like to post.
For example :
- {
- "text": "How to post a simple message to a Cliq channel? "
- }
Now, to send this JSON by making a standard POST request
- curl -X POST -H "Content-type: application/json" -H "Authorization:Zoho-authtoken <authtoken>" https://cliq.zoho.com/api/v2/channelsbyname/<channel_unique_name>/message -d '{"text":"How to post a simple message to a Cliq Channel?"}'
Sample POST request using cURL:
If the channel uniquename is 'market-stats' and the authtoken is 'abaijd9ie3n9udnuxc92' then your curl command will be
- wget --post-data="{'text':'How to post a simple message to a Cliq Channel?'}" --header="Content-type:application/json" --header="Authorization:Zoho-authtoken abaijd9ie3n9udnuxc92" https://cliq.zoho.com/api/v2/channelsbyname/market-stats/message
And finally using Powershell :
- Invoke-RestMethod -Uri https://cliq.zoho.com/api/v2/channelsbyname/market-stats/message -Method Post -Headers @{"Authorization" = "Zoho-authtoken abaijd9ie3n9udnuxc92"} -ContentType 'application/json' -Body '{"text" : "How to post a simple message to a Cliq Channel?'"}'
Go on and try posting a message in a channel! After all, its simple. 
Suggestions and discussions are welcome!
Best,
Manasa
Cliq