Add two separate messages with circuit rest api in the same subject box - circuit-sdk

I am trying to write two different messages to the same subject bot after each other. But any time a new subject with the same title is posted.
I use the rest api post call and tried this:
curl --insecure -X POST https://yourcircuit.com/rest/v2/webhooks/incoming/xxxx -d '{"text": "foobar1", "subject": "My fancy title"}'
curl --insecure -X POST https://yourcircuit.com/rest/v2/webhooks/incoming/xxxx -d '{"text": "foobar2", "subject": "My fancy title"}'
I assumed two messages under the same title box inside the circuit conversation.
What is shows:
What I want to achive:
Does anybody know how to achive this?

That is not supported with webhooks. This could be done with the regular REST API /conversations/{convId}/messages/{itemId}. See https://circuitsandbox.net/rest/v2/swagger/ui/index.html

You can try this using the swagger ui at https://circuitsandbox.net/rest/v2/swagger/ui/index.html
Here is the corresponding http request:
curl -X POST "https://circuitsandbox.net/rest/v2/conversations/05bd75f1-a8d5-40c0-b24a-28710ec1a57f/messages/cde0b57e-7f1d-4ffb-b2af-a1b7c7c9fa06" \
-H "accept: application/json" \
-H "authorization: Bearer ot-4f70c19edc6f43c4b89b4d39b4440000" \
-H "content-type: application/x-www-form-urlencoded" \
-d "content=hello"
Note that the token above has been invalidated. You need to use your own conversation ID, parent item ID and access token.
And here is how it looks in Circuit:

Related

How to import json report through automation using REST API and XRay for JIRA and Cucumber + Xray

I can manually import execution result(report.json) through jira and its giving proper status.But i want to achieve through automation i am unable to do so
How to do so
i tried using below curl command in terminal ..was unable to get expected result
curl -H "Content-Type: application/json" -X POST -u username:password --data #report.json http://myurl.net/rest/raven/1.0/import/execution/cucumber
Note that the curl request you showed is tailored for Xray on Jira server and from the screenshot you're showing, it seems that you're using Xray on Jira Cloud. That requires that you have a token that you need to obtain first of all using another request.
If you're doing it by "hand" (i.e. from the command line), you would need to so something like:
token=$(curl -H "Content-Type: application/json" -X POST --data #"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"')
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
My cloud_auth.json is something like:
{ "client_id": "215FFD69....","client_secret": "1c00f8f2c..." }
Please check in more detail the authentication API and the endpoint for importing cucumber results (there are two actually) in the cloud.

How to use a Circuit Bot to publish a message in Circuit Conversation via Rest API Message

I am trying to make post a message in a circuit conversation through a Circuit Bot via Rest API call. Please help.
You have two options:
Use an incoming webhook. This is very simple and does not require OAuth as the webhook url includes token and the specific conversation. Anyone with this url can post to a conversation. There are both option, posting as yourself, or posting as a bot. If you want to post as a bot, then you first need to create a webhook bot using the "Manage Application > Custom Apps" page. For more information see https://www.circuit.com/unifyportalfaqdetail?articleId=164448 and other webhook articles on these FAQ pages.
Here is s curl example to post a message on an incoming webhook url.
curl https://circuitsandbox.net/rest/webhooks/incoming/9999999-0b95-4088-b272-5bef80f8e68e -H "Content-Type: application/json" -d '{"text":"hello world"}'
Create an actual OAuth 2.0 bot via "Manage Application > Custom Apps" and use the regular REST API (https://circuitsandbox.net/rest/v2/swagger/ui/index.html). There are several REST examples on github. See https://github.com/circuit/circuit-REST-bot for a simple REST bot example.
This is done in two steps :
use the authentication endpoint to obtain a token for your bot
use the messages endpoint (and the token from step 1) to publish the message
Assuming you already have :
a bot (client id, client secret)
conversation ID (the bot must be a participant of it)
Step 1 : Getting the token
curl -X POST
https://<circuitBaseUrl>/oauth/token \
-H 'Authorization: Basic <base64-encode(<clientId>:<clientSecret>)>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&scope=WRITE_CONVERSATIONS'
Get the access_token from the response
Step 2 : Use the REST API to post
curl -X POST \
https://<circuitBaseUrl>/rest/v2/conversations/<conversationId>/messages \
-H 'Authorization: Bearer <access_token>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: beta.circuit.com' \
-d content=hello%20from%20postman
Welcome to the Circuit Developer Community ;-)

Using cURL in API where a Date Array is required

I'm trying to create a simple cURL request to grab some JSON data and dump it into a file. Tried using command-line and PowerShell but can't
figure out how to use a date array as required in the documentation (https://api.officevibe.com/docs/engagement)
The support at OfficeVibe is ridiculous, unless you know exactly what you're doing they're not very willing to help and any examples provided don't actually work (as i'm assuming they need to be part of a larger app).
Can anyone offer some advice on how i can get this working? (The Bearer ID isn't our actual ID)
Example from OfficeVibe which doesn't work in command-line or PowerShell:
c:\temp\curl.exe -k -X POST https://app.officevibe.com/api/v2/engagement -H 'Authorization: Bearer 1234' -H 'Content-Type: application/json' -d '{"dates" : ["2019-04-01"]}' -o c:\temp\engagement.json
Many thanks
The answer was as easy - all i needed to do was add a backslash before the double-quote:
c:\temp\curl.exe -k -X POST https://app.officevibe.com/api/v2/engagement -H 'Authorization: Bearer 1234' -H 'Content-Type: application/json' -d '{\"dates\" : [\"2019-04-01\"]}'

How to get a Yelp access token

I am trying to use the yelp fusion api but cannot seem to find out how to format the url. I have read the get started page but do not understand it. I just need to know where to put what. This is what I have so far:
https://api.yelp.com/oauth2/token?grant_type=client_credentials&client_id=ID&client_secret="CLIENT SECRET"
When I load this url it says "VALIDATION_ERROR." What am I doing wrong?
The grant_type,client_id and client_secret should be sent in application/x-www-form-urlencoded format in the POST call.
curl -X POST \
https://api.yelp.com/oauth2/token \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET'

Unable to call Azure Management Events REST API

I am trying to use the rest api found here: https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx to get the azure events from my subscription. I have followed the instructions very carefully, but my GET requests return a 400 error:
{"Code":"BadRequest","Message":"The $filter query parameter value is invalid."}
My cURL request can be seen below. I've redacted any private info
curl -X GET -H "Authorization: bearer XXX" -H "content-type: application/json" "https://management.azure.com/subscriptions/YYY/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&$filter=eventTimestamp%20ge%20%272016-07-25T22:00:37Z%27%20and%20eventTimestamp%20le%20%272016-07-25T23:36:37Z%27%20and%20eventChannels%20eq%20%27Admin,%20Operation%27"
I have tried many variations of the filter param, but I think this should be correct. Each space was replaced with a %20, and each ' was replaced with a %27.
If anyone can please inform me as to what the correct query should look like i'd really appreciate it!
Thanks!
Please try to change the double quotes over the url to the single quotes. And it works fine on my side after modification.
E.G.,
curl -X GET -H 'Authorization: bearer <token>' -H 'content-type: application/json' 'https://management.azure.com/subscriptions/XXX/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&$filter=eventTimestamp%20ge%20%272016-07-25T22:00:37Z%27%20and%20eventTimestamp%20le%20%272016-07-25T23:36:37Z%27%20and%20eventChannels%20eq%20%27Admin,%20Operation%27'