I'm using postman to make rest requests to the azure API to run a pipeline that is in synapse, in terms of permissions and the token I already get them and it works, the problem is that the pipeline receives 3 parameters but I don't know how to pass them, so I have this request, example:
https://hvdhgsad.dev.azuresynapse.net/pipelines/pipeName/createRun?api-version=2020-12-01
and the parameters I added them in the body:
{
"parameters": {
"p_dir": {
"type": "string",
"defaultValue": "val1"
},
"container": {
"type": "string",
"defaultValue": "val"
},
"p_folder": {
"type": "string",
"defaultValue": "val3"
}
}
}
but when I validate the run that was launched with the request I get this.
{
"id": "xxxxxxxxxxxxxxx",
"runId": "xxxxxxxxxxxxxxxxxxxxx",
"debugRunId": null,
"runGroupId": "xxxxxxxxxxxxxxxxxxxx",
"pipelineName": "xxxxxxxxxxxxxxxxx",
"parameters": {
"p_dir": "",
"p_folder": "",
"container": ""
},
"invokedBy": {
"id": "xxxxxxxxxxxxxxxxx",
"name": "Manual",
"invokedByType": "Manual"
},
"runStart": "2021-07-20T05:56:04.2468861Z",
"runEnd": "2021-07-20T05:59:10.1734654Z",
"durationInMs": 185926,
"status": "Failed",
"message": "Operation on target Data flow1 failed: {\"StatusCode\":\"DF-Executor-SourceInvalidPayload\",\"Message\":\"Job failed due to reason: Data preview, debug, and pipeline data flow execution failed because container does not exist\",\"Details\":\"\"}",
"lastUpdated": "2021-07-20T05:59:10.1734654Z",
"annotations": [],
"runDimension": {},
"isLatest": true
}
the params are empty, so I don't know what's wrong or missing.
what is the correct way to pass them???
ref: https://learn.microsoft.com/en-us/rest/api/synapse/data-plane/pipeline/create-pipeline-run#examples
Just created an account to answer this as i've had the same issue.
I resolved this by just having the name of the variable and its subsequent value in the body JSON.
e.g.
{"variable": "value", "variable": "value"}
Found this by following the documentation you had posted, under request body it passes the name of the variable and the value directly into the JSON body.
{
"OutputBlobNameList": [
"exampleoutput.csv"
]
}
This particular example is a list/array so it confused me by adding the brackets [] if you are passing string parameters this is unneeded.
Related
I was looking for an API which gives me the details of a Azure Datafactory Pipeline
including start time,end time, duration etc. This is required to generate a report without manually looking into the ADF monitoring window
You can get a list of pipeline runs using Pipeline Runs - Query By Factory and then for each result run [Pipeline Runs - Query By Factory]
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/queryPipelineRuns?api-version=2018-06-01
Checkout the sample request here
You can pick the necessary fields from the response body.
{
"value": [
{
"runId": "2f7fdb90-5df1-4b8e-ac2f-064cfa58202b",
"pipelineName": "examplePipeline",
"parameters": {
"OutputBlobNameList": "[\"exampleoutput.csv\"]"
},
"invokedBy": {
"id": "80a01654a9d34ad18b3fcac5d5d76b67",
"name": "Manual"
},
"runStart": "2018-06-16T00:37:44.6257014Z",
"runEnd": "2018-06-16T00:38:12.7314495Z",
"durationInMs": 28105,
"status": "Succeeded",
"message": "",
"lastUpdated": "2018-06-16T00:38:12.7314495Z",
"annotations": [],
"runDimension": {
"JobId": "79c1cc52-265f-41a5-9553-be65e736fbd3"
}
},
{
"runId": "16ac5348-ff82-4f95-a80d-638c1d47b721",
"pipelineName": "examplePipeline",
"parameters": {
"OutputBlobNameList": "[\"exampleoutput.csv\"]"
},
"invokedBy": {
"id": "7c5fd7ef7e8a464b98b931cf15fcac66",
"name": "Manual"
},
"runStart": "2018-06-16T00:39:49.2745128Z",
"runEnd": null,
"durationInMs": null,
"status": "Cancelled",
"message": "",
"lastUpdated": "2018-06-16T00:39:51.216097Z",
"annotations": [],
"runDimension": {
"JobId": "84a3c493-0628-4b44-852f-ef5b3a11bdab"
}
}
]
}
And here is a simple WebActivity setup:
Further, you can find similar queries answered by me here and here
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"
}
I have VS2019 and trying to create Logic Apps which includes SQL connection.
I deploy this LogicApps with Azure DevOps and getting error. I do not what is purpose of sql_1_privacySetting and what are possible values I could use. Specially I'm wondering how to set values in ARM.
ERROR:
##[error]Deployment template validation failed: 'The provided value 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Common.Entities.TemplateGenericProperty`1[Newtonsoft.Json.Linq.JToken]' for the template parameter 'sql_1_privacySetting' at line '1' and column '1605' is not valid. The parameter value is not part of the allowed value(s): 'None,Private,Organizational,Public'.'.
LogicApp.parameters.json
"sql_1_encryptConnection": {
"value": false
},
"sql_1_privacySetting": {
"value": ""
},
LogicApp.json
{
"type": "MICROSOFT.WEB/CONNECTIONS",
"apiVersion": "2018-07-01-preview",
"name": "[parameters('sql_1_Connection_Name')]",
"location": "[parameters('logicAppLocation')]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'sql')]"
},
"displayName": "[parameters('sql_1_Connection_DisplayName')]",
"parameterValues": {
"server": "[parameters('sql_1_server')]",
"database": "[parameters('sql_1_database')]",
"username": "[parameters('sql_1_username')]",
"password": "[parameters('sql_1_password')]",
"encryptConnection": "[parameters('sql_1_encryptConnection')]",
"privacySetting": "[parameters('sql_1_privacySetting')]",
"sqlConnectionString": "[parameters('sql_1_sqlConnectionString')]"
}
}
}
In my LogicApp.json it has these as the possible privacySetting allowed values:
"sql_1_privacySetting": {
"type": "string",
"metadata": {
"description": "Privacy Setting"
},
"allowedValues": [
"None",
"Private",
"Organizational",
"Public"
]
},
Set the
values as follows if you want it blank
"sql_1_privacySetting": {
"value": "None"
}
Options are
"None",
"Private",
"Organizational",
"Public"
Have built an Azure logic app with a HTTP trigger that receives a JSON file, provides a response, then attempts to send the payload to a Service Bus queue. Kept getting an status 400 error, so tried adding a parse JSON step, however am getting an invalid template per shot below.
Azure logic app
parse JSON error
The response is working correctly, with the payload being correctly displayed at the initiating website.
successful response
The JSON data in the schema is as follows. EDIT: Revised schema to include "null" per Rick's suggestion below.
{
"items": {
"properties": {
"Entry Price": {
"type": [
"string",
"null"
]
},
"Exit Price": {
"type": [
"string",
"null"
]
},
"Gain $": {
"type": [
"string",
"null"
]
},
"New Stop": {
"type": [
"string",
"null"
]
},
"ReceivedDate": {
"type": [
"string",
"null"
]
},
"ReceivedTime": {
"type": [
"string",
"null"
]
},
"Status": {
"type": [
"string",
"null"
]
},
"Stop": {
"type": [
"string",
"null"
]
},
"Symbol": {
"type": [
"string",
"null"
]
},
"Tranche": {
"type": [
"string",
"null"
]
}
},
"required": [
"Symbol",
"Status",
"ReceivedDate",
"ReceivedTime"
],
"type": "object"
},
"type": "array"
}
I have spent days looking at forums and trying a number of suggested fixes, however am unable to get the app to execute without error.
Appreciate any ideas or suggestions to fix. Thanks.
It looks like you are passing in a null value for the property content, while the schema has it as a required property.
You can solve this by changing the definition in the schema for content to be as follows:
"content":{
"type":[
"string",
"null"
]
}
More information (and source) here: Parsing JSON with null-able properties in Logic Apps
There is also default values, that could be considered, but everything depends on the context your logic app operates in.
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.