Postman - how to get all attribute values and setEnvironment them? - get

In my body return:
{
"status": "OK",
"msg": "",
"data": {
"events": {
"1-7396679c-4597-4253-9b8e-f135017c791c": {
"event": "verbose"
},
"2-ee86609a-5c86-4662-a94d-9d4c0e3c836d": {
"event": "verbose"
},
"3-49caf28d-5d68-4606-b487-0284d05ecbc0": {
How can I setEnvironmentVariable about the first events attribute ("1-7396679c-4597-4253-9b8e-f135017c791c"). I didnt find any information because its always about the value but not the attribute.
How, for each attribute events value, setEnvironmentVariable (like a while for all the events attributes)
Thanks for your answer,

Related

Azure REST API for running builds or pipelines

I am trying to automate the creation of Azure Pipelines for a particular branch using their REST api.
However, I am struggling to use almost all their API's, as their documentation lacks examples.
Things like List and Get are simple enough.
However, when it comes to queuing a build:
https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-6.0
POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=6.0
{
"parameters": <parameters>, // how do i send paramters
"definition": {
"id": 1
},
"sourceBranch": "refs/heads/feature/my-pipeline",
"sourceVersion": "d265f01aeb4e677a25725f44f20ceb3ff1d7d767"
}
I am currently struggling to send parameters.
I have tried:
Simple JSON like:
"parameters": {
"appId": "bab",
"platform": "android",
"isDemo": true
}
and stringify version of JSON like:
"parameters": "{\"appId\": \"bab\",\"platform\": \"android\",\"isDemo\": true}"
but none seems to work.
It keeps giving me the error:
{
"$id": "1",
"customProperties": {
"ValidationResults": [
{
"result": "error",
"message": "A value for the 'appId' parameter must be provided."
},
{
"result": "error",
"message": "A value for the 'platform' parameter must be provided."
},
{
"result": "error",
"message": "A value for the 'isDemo' parameter must be provided."
}
]
},
"innerException": null,
"message": "Could not queue the build because there were validation errors or warnings.",
"typeName": "Microsoft.TeamFoundation.Build.WebApi.BuildRequestValidationFailedException, Microsoft.TeamFoundation.Build2.WebApi",
"typeKey": "BuildRequestValidationFailedException",
"errorCode": 0,
"eventId": 3000
}
The docs is very unclear in how to send this data: https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-6.1#propertiescollection
Thank you very much for you help.
I believe you cannot pass runtime parameters trough the Queue API. Instead, use Runs API
With that, your request body (use Content-type: application/json) should look something similar to this:
{
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/feature/my-pipeline"
}
}
},
"templateParameters": {
"appId": "bab"
"platform": "android"
"isDemo": true
}
}
I just realized that in the api-version=6.0 you can also send templateParameters on the Queue Service:
POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?sourceBuildId={BUILD_BUILDID}&api-version=6.0
{
"templateParameters": { "doReleaseBuild": "True" },
"definition": {
"id": 1
},
"sourceBranch": "refs/heads/feature/my-pipeline",
"sourceVersion": "d265f01aeb4e677a25725f44f20ceb3ff1d7d767"
}

Use "response_action" to respond to view_submission when using botkit

I have a simple modal with view pushed using:
const result = await bot.api.views.open({
trigger_id: message.trigger_id,
view: {
"type": "modal",
"submit": {
"type": "plain_text",
"text": "Submit",
"emoji": true
},
"title": {
"type": "plain_text",
"text": "Request",
"emoji": true
},
"blocks": [
{
"type": "input",
"block_id" : "accblock",
"element": {
"type": "plain_text_input",
"action_id": "account_name",
"multiline": false
},
"label": {
"type": "plain_text",
"text": "Account Name",
"emoji": true
}
}
]
}
});
I need to add error to the block if certain value is entered on view_submission. I understand I should send response with the following JSON:
{
response_action: 'errors',
errors: {
"ticket-desc": 'I will never accept a value, you are doomed!'
}
}
But, how do I send it? I've tried using bot.httpBody(). Does this JSON need to be included as the view object? Any help is appreciated.
bot.httpBody() is the method you need.
Make sure that the key to the errors dictionary matches the block_id of the element you are providing an error message for.
In your case this will work:
bot.httpBody({
response_action: 'errors',
errors: {
accblock: 'Your account name is invalid or in use.'
}
})
You do not need to JSON.stringify the response message and indeed the process fails if you do.

Need an expression to use in an azure logic app in-order to fetch an element of a JSON

I have a JSON Content in my Logic App. I need to fetch only a particular element (value of commitId) from the JSON and not all attributes. Can you please help me to write an appropriate expression !
{
"count": 1,
"value": [
{
"commitId": "zzzzzzzzzzzzzzzzzzzz",
"author": {
"name": "mahesh",
"email": "mahesh#xyz.com",
"date": "2020-03-27T09:43:03Z"
},
"committer": {
"name": "mahesh",
"email": "mahesh#xyz.com",
"date": "2020-03-27T09:43:03Z"
},
"comment": "Added task markdown file.",
"changeCounts": {
"Add": 1,
"Edit": 0,
"Delete": 0
},
"changes": [
{
"sourceServerItem": "/Books",
"changeType": "edit"
}
],
"url": "https://dev.azure.com/company/aaaabbbbbbb/_apis/git/repositories/ccccddddd/commits/eeeeeefffff",
"remoteUrl": "https://dev.azure.com/company/DataEngineering/_git/Test/commit/aaabbbbccccdddd"
}
]
}
You just need to use "Parse JSON" action to parse your json data and then please refer to the expression below:
The whole expression in the screenshot above is:
body('Parse_JSON')?['value'][0]?['commitId']
Then we can get the value of commitId after running it.

Acumatica API insert data "Bad Request"

I'm trying to insert a stock item into Acumatica using the API, but I'm getting a 400 error - Bad Request. I'm using HttpClient to login, retrieve a stock item, and send the insert request. All is working except the insert request. I have tried the following url (including expand parameter):
http://localhost/AcumaticaERP/entity/Default/6.00.001/StockItem?$expand=Attributes,CrossReferences,UOMConversions,VendorDetails,WarehouseDetails
... and also the following url (without expand parameter)
http://localhost/AcumaticaERP/entity/Default/6.00.001/StockItem
I'm calling via HttpClient PutAsync, passing in the URLs mentioned above, and the data is JSON from a stock item retrieved with the API, and which doesn't exist in the current db.
client.PutAsync(insertUrl, new StringContent(data, Encoding.UTF8, "application/json")).Result;
Any ideas what I'm missing?
NEW DETAILS:
After further debugging and testing with Postman, the error from the PUT seems to be "Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1." The JSON was taken directly from a GET though, so I'm not sure what the problem could be. Below is the JSON returning an error from the PUT.
[
{
"id": "cc27ce56-6302-4f1b-97aa-49cca3ed32ea",
"rowNumber": 1,
"note": "",
"Attributes": [],
"BaseUOM": {
"value": "EA"
},
"CrossReferences": [],
"DefaultIssueLocationID": {
"value": "R1S1"
},
"DefaultReceiptLocationID": {
"value": "RECEIVING"
},
"DefaultWarehouseID": {
"value": "WHOLESALE"
},
"Description": {
"value": "tonyitem2"
},
"ImageUrl": {},
"InventoryID": {
"value": "TONYITEM2"
},
"IsAKit": {
"value": false
},
"ItemClass": {
"value": "CONSUMER 300TOYS"
},
"ItemStatus": {
"value": "Active"
},
"ItemType": {
"value": "Finished Good"
},
"LastModified": {
"value": "2018-08-03T12:09:19.907-04:00"
},
"LotSerialClass": {
"value": "NOTTRACKED"
},
"PurchaseUOM": {
"value": "EA"
},
"SalesUOM": {
"value": "EA"
},
"UOMConversions": [],
"VendorDetails": [],
"Volume": {
"value": 0
},
"WarehouseDetails": [
{
"id": "3ca5ea4c-c651-498e-8e6c-49119481982c",
"rowNumber": 1,
"note": "",
"DefaultIssueLocationID": {
"value": "R1S1"
},
"DefaultReceiptLocationID": {
"value": "RECEIVING"
},
"IsDefault": {
"value": true
},
"QtyOnHand": {
"value": 0
},
"WarehouseID": {
"value": "WHOLESALE"
},
"custom": {},
"files": []
}
],
"Weight": {
"value": 0
},
"custom": {},
"files": []
}
]
I also tried removing the brackets surrounding the JSON, and then the error is:
"No entity satisfies the condition.". Could the issue be that the ids have GUIDs, but I'm trying to do an insert? How do you indicate that the PUT is supposed to be inserting?
I finally got the PUT to insert. What finally worked was removing the wrapping braces "[" and "]" around the entire JSON; plus removing all "id", "rowNumber", "custom", and "files" fields, and all empty collections (e.g. Attributes, CrossReferences) in my JSON. I'm not sure which of these being removed resolved it and allowed me to insert, but it finally worked.
It's real unfortunate that the JSON you retrieve via GET can't be inserted via PUT without stripping all of this out first though. What a pain.

expectUserResponse field being ignored

I'm seeing a strange behavior. I send a basic card with some information but regardless the expectUserResponse json flag, the conversation is not closed in Google Assistant. How come? Is it a bug? Can someone confirm?
JSON that is returned that contains the card:
{
"data": {
"google": {
"expectUserResponse": false,
"systemIntent": {
"intent": "actions.intent.TEXT"
},
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Some text",
"displayText": "Some text"
}
},
{
"basicCard": {
"title": "A title",
"formattedText": "A long text",
"buttons": [
{
"title": "Title button",
"openUrlAction": {
"url": "http://www.google.com"
}
}
]
}
}
]
}
}
}
}
(From https://plus.google.com/102582215848134314158/posts/PG3NbHG9dsr)
The problem is that you're specifying systemIntent. This indicates what system Intent should be used to handle the response.
But you don't want to handle a response, as you've tried to indicate with "expectUserResponse": false.
Given the conflicting information - it chooses to honor the systemIntent setting and waits for the response.
The solution is to remove the systemIntent section completely. In general, unless you're requesting permission or one of the other helper Intents, you can leave this section out anyway since you're using API.AI.

Resources