In BLiP, one schedule message works but many message at the same time does not - chatbot

Im using BLiP and i want to schedule 3 messages after 5 minutes of the last interaction with the user, one call works and others don't.
POST https://msging.net/commands HTTP/1.1
Content-Type: application/json
Authorization: Key {YOUR_TOKEN}
{
"id": "1",
"to": "postmaster#scheduler.msging.net",
"method": "set",
"uri": "/schedules",
"type": "application/vnd.iris.schedule+json",
"resource": {
"message": {
"id": "ad19adf8-f5ec-4fff-8aeb-2e7ebe9f7a67",
"to": "destination#0mn.io",
"type": "text/plain",
"content": "Scheduling test."
},
"when": "2016-07-25T17:50:00.000Z",
"name": "New Schedule"
}
}

If your id parameter is hard-coded/constant, it will throw an exception inside BLiP's API if more than one request is sent within a short timeframe
Either change it to a randomly generated GUID or insert a delay between calls to fix it.

Related

For unsuccessful actions, there should not be outputs

I'm trying to test my workflow with HTTP request action... And when I select Status "Failure" - I can't add Output. But when I send a request without testing - I can see Output from the failed action (i.e. Status code, Body, Headers).
So, how can I test this one with Output parameters? Actually, I have to handle Status code in the subsequent actions.
My workflow seems like this:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Bad": {
"inputs": {
"body": "Bad: #{outputs('HTTP')['statusCode']}",
"statusCode": 503
},
"kind": "http",
"runAfter": {
"HTTP": [
"TIMEDOUT",
"FAILED"
]
},
"type": "Response"
},
"HTTP": {
"inputs": {
"method": "GET",
"uri": "#{appsetting('externalServiceUrl')}/api/entities/"
},
"runAfter": {},
"type": "Http"
},
"Success": {
"inputs": {
"body": "Success",
"statusCode": 200
},
"kind": "http",
"runAfter": {
"HTTP": [
"Succeeded"
]
},
"type": "Response"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
},
"kind": "Stateful"
}
Actually, I have to handle Status code in the subsequent actions.
You just need to change the status as Succeeded and in Status Code when you scroll down you can find a bunch of status codes that you can set.
Additionally, To Handle Status Code further you can also use the Condition action of Control check if the HTTP connector has satisfied the conditions that we are looking for. Here is my logic app workflow.
So the Success executes for 200 and 202 status and rest all codes comes under bad action when executed.
My solution in Acceptance tests to test this workflow - I just mocked API using WireMock.
But lack of possibility to test with the default functionality (without Kludge) seems like a bug.

Telegram: no answer sent with answerInlineQuery

I make a POST request in response to an inline request with the following url
https://api.telegram.org/bot<some-token>/answerInlineQuery
and body
{
"inline_query_id": "${inline_query_id}",
"result": {
"InlineQueryResultArticle": [
{
"type": "article",
"id": "111",
"title": "some-title",
"input_message_content": {"message_text": "TEXT 1"}
}
]
}
}
Telegram responds 200 OK but there is no changes/answers in the bot.
I've also tried so many modifications of the body to sent. No one was successfull, but no one error I`ve got too.
Finally, this one works.
{
"inline_query_id": "${inline_query_id}",
"results": [{
"type": "article",
"id": "111",
"title": "some-title",
"input_message_content": {"message_text":"TEXT 1" }
}]
}
It needs results instead of result. And no definition of InlineQueryResultArticle

How to create Azure DevOps task via rest api

I wrote some PowerShell functions to help me create user stories a bit faster, and this all works great, but now I am stuck figuring out how to create Tasks for a User Story/Work Item, and obviously having them be assigned to a specific Work Item.
I also can't find any documentation describing this.
I almost imagine that I need use the uri "https://dev.azure.com/$($Organisation)/$Project/_apis/wit/workitems/`$Task?api-version=5.1" but I can't see how to associate it with a work item as part of this, or after.
Can anyone help or point me at some actual documentation for this, please?
Edit: While looking for something else, I stumbled across this, but sadly that errors out for me, so it might be deprecated by now...
Edit; Thanks for the help everyone. This now works for me
This is my code in case it becomes useful for someone some day in the future:
#96116 is the parent work item, 96113 the child task
$ContentType = "application/json-patch+json"
$Token = System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PersonalAccessToken)"))
$Header = #{Authorization = 'Basic ' + $Token;accept=$ContentType}
$uri = "https://dev.azure.com/$Organisation/$Project/_apis/wit/workitems/96113?api-version=6.1-preview.3"
$body= #'
[
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/$Organisation/$Project/_apis/wit/workitems/96113",
"attributes": {
"isLocked": false,
"name": "Parent"
}
}
}
]
'#
Invoke-RestMethod -Uri $uri -Method PATCH -Headers $Header -Body $Body -ContentType $contentType
You can follow the steps below to create a new Task, and link a specified User Story as the Parent of this new Task:
Use the endpoint "Work Items - Create" to create the new Task.
Use the endpoint "Work Items - Update" to link the specified User Story as the Parent.
Request URI
PATCH https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.1-preview.3
Required Header
Content-Type: application/json-patch+json
Request Body
[
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
// This is the URL of the linked parent work item.
"url": "https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{parent work item ID}",
"attributes": {
"isLocked": false,
"name": "Parent"
}
}
}
]
I have tested this method, it can work fine as expected.
As mentioned above, adding a relation can be done after creation with a separate PATCH request, but you can also combine multiple Work Item Tracking requests in a single call. You need to POST to the batch endpoint and send an array of JsonPatchDocuments:
PATCH https://dev.azure.com/{organization}/{project}/_apis/wit/$batch?api-version=2.2
"Content-Type": "application/json"
"Accept": "application/json"
"Authorization": "Basic {PAT}"
[
{
"method": "PATCH",
// Replace $Task below with the WIT you want to create
"uri": "/{Project}/_apis/wit/workitems/$Task?api-version=2.2",
"headers": { "Content-Type": "application/json-patch+json" },
"body": [
{ "op": "add", "path": "/fields/System.Title", "value": "Customer can sign in using their Microsoft Account" },
// Indicates new work item instead of an update. Each new work item uses a unique negative number in the batch.
{ "op": "add", "path": "/id", "value": "-1" },
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/{organization}/{project}_apis/wit/workitems/{work item id to link to}"
}
}
]
}
]
With this API you can also create a tree of work items in a single call. You use the negative IDs to link workitems together and they ge translated to their real work item ids as the batch is executed.
Docsr for the batch API are here:
Work Item Tracking - Batch REST API
It looks like Microsoft has documentation for creating, deleting, and updating work items.
Your guess was close. Here's the provided example:
Request
POST https://dev.azure.com/fabrikam/{project}/_apis/wit/workitems/${type}?api-version=6.1-preview.3
Body
[
{
"op": "add",
"path": "/fields/System.Title",
"from": null,
"value": "Sample task"
}
]
Response
{
"id": 131489,
"rev": 1,
"fields": {
"System.AreaPath": "CustomProcessPrj",
"System.TeamProject": "CustomProcessPrj",
"System.IterationPath": "CustomProcessPrj",
"System.WorkItemType": "Task",
"System.State": "New",
"System.Reason": "New",
"System.CreatedDate": "2017-10-06T01:04:51.57Z",
"System.CreatedBy": {
"displayName": "Jamal Hartnett",
"url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
"_links": {
"avatar": {
"href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
}
},
"id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
"uniqueName": "fabrikamfiber4#hotmail.com",
"imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
"descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
},
"System.ChangedDate": "2017-10-06T01:04:51.57Z",
"System.ChangedBy": {
"displayName": "Jamal Hartnett",
"url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
"_links": {
"avatar": {
"href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
}
},
"id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
"uniqueName": "fabrikamfiber4#hotmail.com",
"imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
"descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
},
"System.Title": "Sample task",
"Microsoft.VSTS.Common.StateChangeDate": "2017-10-06T01:04:51.57Z",
"Microsoft.VSTS.Common.Priority": 2
},
"_links": {
"self": {
"href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/131489"
},
"workItemUpdates": {
"href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/131489/updates"
},
"workItemRevisions": {
"href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/131489/revisions"
},
"workItemHistory": {
"href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/131489/history"
},
"html": {
"href": "https://dev.azure.com/fabrikam/web/wi.aspx?pcguid=20cda608-32f0-4e6e-9b7c-8def7b38d15a&id=131489"
},
"workItemType": {
"href": "https://dev.azure.com/fabrikam/aaee31d9-14cf-48b9-a92b-3f1446c13f80/_apis/wit/workItemTypes/Task"
},
"fields": {
"href": "https://dev.azure.com/fabrikam/_apis/wit/fields"
}
},
"url": "https://dev.azure.com/fabrikam/_apis/wit/workItems/131489"
}

Fetching multiple event details in Office 365

I need to fetch information related to eventId from office 365 for multiple events.
Is there a way I can get that info in a single REST call?
I want specific events only (based on eventId's only)
A batch request may be what you are looking for.
See json Batching Documentation for more information
Keep in mind that batching is currently limited to 20 requests per message (known issues)
Example:
You will need to send a POST Message to the batch endpoint
https://graph.microsoft.com/v1.0/$batch
inside the body you will need to include your requests:
Note: do not include the server url (https://graph.microsoft.com/v1.0/) in the url property or the request will fail with "BadRequest - Invalid request Uri".
Request-Body:
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "/me/calendarview?startdatetime=2018-03-01T18:31:34.206Z&enddatetime=2018-03-12T18:31:34.206Z"
},
{
"id": "2",
"method": "GET",
"url": "/me/events/{someEventId}"
},
]
}
When the server has processed all requests an response array containing the results will be sent back:
Server-Response:
{
"responses": [
{
"id": "2",
"status": 200,
"headers": {
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8",
"ETag": "W/\"Z+ICSvkiAfZX7XWQAZ6IH==\""
},
"body": {
// the event object
}
},
{
"id": "1",
"status": 200,
"headers": {
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
},
"body": {
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('aUserID')/calendarView",
"value": [
// list of found event-objects
]
}
}
]
}

Jira Rest API: Requesting issue(s) of a specific user in one or more projects (Beginner)

For testing and practice purposes I want to create a specific request in Jira by using its REST api:
I want to list all issues from a specific user in one or more specific projects.
I tried it with SOAP UI but I was not able to create or get my results with easy GET-HTTP requests (I don't know how to combine more values and parameter together). The other way would be to use a script language but here I don't know what to use.
The documentation is somewhat confusing for a beginner like me and I would like to know how combine different values and paramter and how to start in an easy way.
Try to use advance rest client for chrome browsers to make your Rest requests.
The examples below (from official documentation) are for Curl usage but its simple to pass them to advance rest client. Dont forget the authentication.
Link to advance rest client
Example of create issue:
Request
curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
Data
{
"fields": {
"project":
{
"key": "TEST"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Bug"
}
}
}
Response
{
"id":"39000",
"key":"TEST-101",
"self":"http://localhost:8090/rest/api/2/issue/39000"
}
Example of making a query issue:
Request:
curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/search?jql=assignee=fred
Response:
{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 6,
"issues": [
{
"expand": "html",
"id": "10230",
"self": "http://kelpie9:8081/rest/api/2/issue/BULK-62",
"key": "BULK-62",
"fields": {
"summary": "testing",
"timetracking": null,
"issuetype": {
"self": "http://kelpie9:8081/rest/api/2/issuetype/5",
"id": "5",
"description": "The sub-task of the issue",
"iconUrl": "http://kelpie9:8081/images/icons/issue_subtask.gif",
"name": "Sub-task",
"subtask": true
},
},
"customfield_10071": null
},
"transitions": "http://kelpie9:8081/rest/api/2/issue/BULK-62/transitions",
},
{
"expand": "html",
"id": "10004",
"self": "http://kelpie9:8081/rest/api/2/issue/BULK-47",
"key": "BULK-47",
"fields": {
"summary": "Cheese v1 2.0 issue",
"timetracking": null,
"issuetype": {
"self": "http://kelpie9:8081/rest/api/2/issuetype/3",
"id": "3",
"description": "A task that needs to be done.",
"iconUrl": "http://kelpie9:8081/images/icons/task.gif",
"name": "Task",
"subtask": false
},
"transitions": "http://kelpie9:8081/rest/api/2/issue/BULK-47/transitions",
}
]
}