I have a web activity to call a REST API and save it output into a table. But one of its value will not available always. So we need to do a conditional checking while setting its output into a variable activity.
you can see how we have done that in the variable activity.
This is the rest APIs output.
{
"value": {
"id": "464a115fd3cb",
"runId": "464a115fd3cb",
"parameters": {},
"invokedBy": {
"id": "99448303872CU28",
"name": "TRIGGER_TIMESHEET_API",
"invokedByType": "ScheduleTrigger"
},
"isLatest": true
},
"continuationToken": "+RID:~sj5QALRCCB4w5hYAAAAADQ",
"ADFWebActivityResponseHeaders": {
"Pragma": "no-cache"
}
}
Here "continuationToken" will not be a part of all the API responses. So if this value is available in the API response, we need to set that in the variable activity.
In the attached screenshot, you can see that we are setting the variable. But if that key is not available in the API response, it will throw an error.
So we are looking for a solution to check whether that key is existing in the JSON output.
Any help appreciated.
I think you almost get your goal already,please use Set Variable Activity and If-Condition Activity:
Set Variable Activity:
If-Condition Activity to judge the name is empty or not:
Then you could configure the True Activity and False Activity:
Related
I am trying to implement a Get Metadata activity to return the column count of files I have in a single blob storage container.
Get Metadata activity is returning this error:
Error
I'm fairly new to Azure Data Factory and cannot solve this. Here's what I have:
Dataset:Source dataset
Name- ten_eighty_split_CSV
Connection- Blob storage
Schema- imported from blob storage file
Parameters- "FileName"; string; "#pipeline().parameters.SourceFile"
Pipeline:
Name: ten eighty split
Parameters: "SourceFile"; string; "#pipeline().parameters.SourceFile"
Settings: Concurrency: 1
Get Metadata activity: Get Metadata
Only argument is "Column count"
Throws the error upon debugging. I am not sure what to do, (404) not found is so broad I could not ascertain a specific solution. Thanks!
The error occurs because you have given incorrect file name (or) name of a file that does not exist.
Since you are trying to use blob created event trigger to find the column count, you can use the procedure below:
After configuring the get metadata activity, create a storage event trigger. Go to Add trigger -> choose trigger -> Create new.
Click on continue. You will get a Trigger Run Parameters tab. In this, give the value as #triggerBody().fileName.
Complete the trigger creation and publish the pipeline. Now whenever the file is uploaded into your container (on top of which you created storage event trigger), it will trigger the pipeline automatically (no need to debug). If the container is empty and you try to debug by giving some value for sourceFile parameter, it would give the same error.
Upload a sample file to your container. It will trigger the pipeline and give the desired result.
The following is the trigger JSON that I created for my container:
{
"name": "trigger1",
"properties": {
"annotations": [],
"runtimeState": "Started",
"pipelines": [
{
"pipelineReference": {
"referenceName": "pipeline1",
"type": "PipelineReference"
},
"parameters": {
"sourceFile": "#triggerBody().fileName"
}
}
],
"type": "BlobEventsTrigger",
"typeProperties": {
"blobPathBeginsWith": "/data/blobs/",
"blobPathEndsWith": ".csv",
"ignoreEmptyBlobs": true,
"scope": "/subscriptions/b83c1ed3-c5b6-44fb-b5ba-2b83a074c23f/resourceGroups/<user>/providers/Microsoft.Storage/storageAccounts/blb1402",
"events": [
"Microsoft.Storage.BlobCreated"
]
}
}
}
I've introduced a new DAC and a new field on the Sales Order associated to the new DAC key. When trying to retrieve the information through OpenAPI it comes back empty. I'd like to know why and how I can adjust my code to return the information. I've tried both PXSelect and PXSelectReadOnly
Declaring Statement on SOOrderEntry(extension):
public PXSelect<IOCSCompanyBrand, Where<IOCSCompanyBrand.companyBrandNbr,
Equal<Current<SOOrderExt.usrCompanyBrand>>>> CompanyBranding;
When I hit the URL: http://localhost/Acumatica21/entity/AcumaticaExtended21R1/20.200.001/SalesOrder?$select=OrderNbr,CompanyBranding,OrderType,CompanyBrand&$expand=CompanyBranding&$filter=OrderNbr%20eq%20'SO-030003'
This is the data that is returned:
[
{
"id": "f827cb43-9b8a-ec11-a481-747827c044c8",
"rowNumber": 1,
"note": {
"value": ""
},
"CompanyBrand": {
"value": "IO"
},
"CompanyBranding": null,
"OrderNbr": {
"value": "SO-030003"
},
"OrderType": {
"value": "SO"
},
"custom": {}
}
]
Acumatica Version: 21.205.0063
Here's the definition for SalesOrder in the endpoint (which was populated via the GUI)
I ended up opening a Acumatica Developer case and here is their response.
Hi Kyle,
Thanks for your time yesterday.
Endpoint mapping is valid but the fields in the view isn't fetch due the limitation of the filter parameter in the request. Filter parameter optimizes the data that are being fetch. In the case, the customer view isn't fetched. To workaround the limitation, instead of using filter, you can try something like below,
http://localhost/Acumatica/entity/AcumaticaExtended21R1/20.200.001/SalesOrder/SO/SO-030007?$expand=CompanyBranding
You can fetch the record and use expand to get the detail level fields. This way you can avoid the limitation of the filter.
Please check and let me know if you have any questions.
Regards,
Vignesh
I am currently trying to update a pipeline variable at the scope, DEV however, I am having hard time updating that variable. Is it possible to update the variable at a scope other than "Release"? If so, how? Below is the code that I used and the error that I received.
let reqLink = ' https://vsrm.dev.azure.com/'+ organization +'/'+project+'/_apis/release/releases?api-version=5.1';
let reqBody = {
"definitionId": definitionId,
"variables": {
"someVar":
{
"value": "foo",
"scope": "DEV"
}
}
};
sendHttpRequest('POST',reqLink,reqBody).then(response => {
let data = JSON.parse(response);
console.log(data);
});
This is the error that I am receiving:
{"$id":"1","innerException":null,"message":"Variable(s) someVar do not exist in the release pipeline at scope: Release
Scoped variables are defined not on the root level. But on stage level. So you must modify this here:
Here you have variable SomeVer scoped to Stage 1. The easiest way to achieve this will be hit endpoint with GET, manipulate on json and hit endpoint with PUT.
And what I noticed you are hiting release/releases whereas you should hit rather specific release release/releases/{releaseId}. Or maybe your goal is to update definition itself?
Is it possible to update the variable at a scope other than "Release"? If so, how?
The answer is yes.
The REST API you use is to create a release, if you want to update a release pipeline, using:
PUT https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=6.0-preview.4
The request body of the REST API may need detailed information of the release pipeline. Use the following REST API to get it.
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=6.0-preview.4
Then you can modify its response body and use it as the request body of the first REST API.
The property variables doesn't have a property called scope. If you want to update a variable from 'Release' scope to a stage scope, you need to delete the variable's original definition in variables and redefinite it in target environment. Here is an example.
Original script:
{
...
"variables": {
"somevar": {
"value": "foo"
}
},
...
};
The modified script:
{
...
"environments": [
{
"id": {stage id},
"name": DEV
...
"variables": {
"somevar": {
"value": "foo",
},
...
}
],
...
"variables": {},
...
};
Here is the summary: To change the scope of a variable, just move the variable definition to target scope.
I have a logic app with an http action.
As the reply policy allows at most 4 retries I put the activity inside a do-until loop (with max count and timeout) using the http status code as escape variable (until it is 200).
This image should make this more clear
At runtime I get this error
[EDIT]InvalidTemplate. Unable to process template language expressions for action 'HTTPAction'[EDIT]: Unable to process template language expressions for action 'HttpAction' [..] The template language expression 'equals(outputs('HttpAction')['statusCode'], 200)' cannot be evaluated because property 'statusCode' cannot be selected.
Any hints?
Thanks, Alessandro
[EDIT]The http request just works (tried with fiddler), in the workflow i suppose it just doesn't get executed due to the template error (why does it fail at runtime and not in edit mode?)[EDIT]
Going to reply for readable code.
I just made a quick POC to simulate your scenario, but I can't reproduce your issue.
Code of my Do-Until:
"Until": {
"actions": {
"HttpGetMyValues": {
"inputs": {
"headers": {
"Ocp-Apim-Subscription-Key": "#parameters('OcpApimSubscriptionKey')"
},
"method": "GET",
"uri": "https://myendpointuri"
},
"runAfter": {},
"type": "Http"
}
},
"expression": "#equals(outputs('HttpGetMyValues')['statusCode'], 200)",
"limit": {
"count": 1,
"timeout": "PT1M"
},
"runAfter": {},
"type": "Until"
}
I can save and run the Logic App without problems.
Retry policy is configurable, currently only available via code view, but we plan to enable it in designer very soon. Here's the documentation.
"retryPolicy" : {
"type": "<type-of-retry-policy>",
"interval": <retry-interval>,
"count": <number-of-retry-attempts>
}
I know this is late to the game, but the error is due to the condition that ends the 'do-until' loop being contained within the loop itself. You'll need to use a value that is outside of the loop as reference. I suggest:
Creating a variable before the 'do-until' action with the default value as '400'
Using the variable as the value the 'Status code' value needs to equal
Updating (set-variable in Logic Apps) the variable at the end of each loop iteration to equal the 'Status code'.
In the Until control:
Click Edit Advanced Mode
Replace the text with #equals(actions('HTTPAction').status, 'Succeeded')
The code means stop do until loop when the HTTPAction has completed
I have a simple Azure Logic App with the following components:
Recurrence
HTTP Get from HTTPS url
I've tried to configure the next component to save the HTTP response body to OneDrive with OneDrive Connector configured as follows:
FilePath: ApiTest/test.json
Content: #{body('http')}
Content Transfer Encoding: None
This gives the following error:
{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'microsoftonedriveconnector' inputs at line '1' and column '11': 'Template language expression cannot be evaluated: one of string interpolation segment value has unsupported type 'Object'. Please convert the value to string using the 'string()' function.'."}
If I then use #{string(body('http'))} I get:
{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'microsoftonedriveconnector' inputs at line '1' and column '11': 'The template language function 'string' was invoked with an invalid parameter. The value cannot be converted to the target type.'."}
How can I use the body of HTTP Connector and save it to One Drive?
I don't have an answer, but I am wrestling with this very issue right now. I will post if I find a solution and would be very interested in case any one else finds a solution. I do find one thing interesting. There is a header and body option on the consuming end of my Http Connector which works when it runs. The error (as the above poster notes) occurs when passing that value to the next card. But, when I look at the output (link) on the run tab, I see a json value for the header and for the body. Does this need to be wrapped in a json parser?
This works for me just fine and generated the file in the /random/test.txt folder, however I believe the problem in your case is that you are downloading a JSON file which is causing it to be interpreted as an object by the engine.
I'll follow up with the team and maybe we need a "ToJson" call, or a way to "Passthrough", or make "String" more "flexible" (though that could be weird).
"fileContent": {
"Content": "#{body('http')}",
"ContentTransferEncoding": "None"
},
Actions in code view looks like:
"http": {
"type": "Http",
"inputs": {
"method": "GET",
"uri": "http://www.carlosag.net/"
},
"conditions": []
},
"microsoftonedriveconnector": {
"type": "ApiApp",
"inputs": {
"apiVersion": "2015-01-14",
"host": {
"id": "/subscriptions/xxx/resourceGroups/zzz/providers/Microsoft.AppService/apiApps/MicrosoftOneDriveConnector",
"gateway": "https://yyy.azurewebsites.net"
},
"operation": "UploadFile",
"parameters": {
"filePath": "random/test.json",
"fileContent": {
"Content": "#{body('http')}",
"ContentTransferEncoding": "None"
},
"overwrite": true
},
"authentication": {
"type": "Raw",
"scheme": "Zumo",
"parameter": "#parameters('/subscriptions/...')"
}
},
You should try "#body('http')". I believe this will work. "#{body('http')}" is a form of string interpolation: expected output value is string and not a JSON.
I initialized a String variable 'Content' and set the value to the body of the HTTP.
#{body('HTTP')}
And then I convert the String to JSON to read the desired node with an expression.
json(variables('Content'))?['ExcelFile']
I went a step further and base64 decoded to binary in order to upload to Sharepoint. Going to OneDrive would likely be the same.
base64ToBinary(json(variables('Content'))?['ExcelFile'])