Parameterize Parameter in API Body in dataflow - azure-data-factory

below is the image of the dynamic body in Web activity wherein I am leveraging a pipeline parameter
With the above set of configuration and values, the web activity is successfully getting executed.
Now for the same REST API, I am trying to use it as source in dataflow :
with the same aspect of configuration and it is failing with below error :
Dataflow param:
Error:
ailure to read most recent page request: DF-REST_001 - Error response from server: Some({"error":{"code":"DatasetExecuteQueriesError","pbi.error":{"code":"DatasetExecuteQueriesError","parameters":{},"details":[{"code":"DetailsMessage","detail":{"type":1,"value":"The JSON DDL request failed with the following error: Invalid JavaScript property identifier character: }. Path '', line 1, position 7.."}},{"code":"AnalysisServicesErrorCode","detail":{"type":1,"value":"3239182519"}}]}}}), Status code: 400. Please check your request url and body.
Can someone please help what I am doing Wrong?

To use dataflow parameter within the expression builder, we have to concatenate the parameter with our data. Look at the following demonstration.
I am using derived column to show how to use parameters within expression builder. Using the dynamic content same as yours, I get the following output:
'{"queries":[{"query":"{$query}"}],"serializerSettings":{"includeNulls":true}}'
String interpolation does not work in the dataflow expression builder. To get it correctly, you can concatenate the parameter using + to get desired result.
'{"queries":[{"query":"'+$query+'"}],"serializerSettings":{"includeNulls":true}}'
Using the following content in expression builder also works (using concat() function).
concat('{"queries":[{"query":"',$query,'"}],"serializerSettings":{"includeNulls":true}}')

Related

Power Query - Populate column through REST API

I have a list of IDs in Power Query and would like to call and API to return some information about each. As there is no direct API that allows me to pull the information for my entire list, I have to call the API for each row in my table.
The API requires a dynamic access token, which I already have a function that takes care of (GetToken()).
I have followed this guide. The guide adds a custom column for which I have written the following code:
Json.Document(
Web.Contents(
Text.Combine({"https://urlthatholdstheinfo.com/", [id]}), [Headers=[Authorization="Bearer "& GetToken()]]))
When I close the editor, I get this classic error:
"Expression.Error: The 'Authorization' header is only supported when connecting anonymously. These headers can be used with all authentication types: Accept, Accept-Charset, Accept-Encoding, Accept-Language, Cache-Control, Content-Type, If-Modified-Since, Prefer, Range, Referer
I have previously mitigated this in the Data Source Settings by setting the Permission to "Anonymous". However, I can not find this query in those settings, so I don't know where to change this.
I have unsuccessfully been looking for a way to parse a parameter to Web.Content, that tells the query to do this with Anonymous settings, but it does not seem to exist.
I have tried this variation as well, but I get the same error
Any thoughts on what I can do?
UPDATE:
The answer for this post works, with a small addition. After implementing the answer, the error still occurred. It was resolved by creating a blank query with a fixed id number instead of parsing the column as an argument to the function. This allowed me to go to "Data source settings" and change the permission for the query to Anonymous, which also fixed the problem for the function and the custom column.
let
Source =
Json.Document(
Web.Contents(
"https://https://urlthatholdstheinfo.com/id",
[Headers=[Authorization="Bearer "& GetToken()]])),
in
Source
Also, be sure to not have the curly brackets that are in the original code of the question.
If you have a list of IDs you can make a custom function that uses appropriate constructors for RelativePath like David suggests. Here is a function you can paste into a blank query, which you can specify using Invoke Custom Function on your list of IDs:
let
Source = (ID as text) =>
Json.Document(
Web.Contents(
"https://urlthatholdstheinfo.com/",
[
Headers=[Authorization="Bearer "& GetToken()] ,
RelativePath=ID
]
]
)
)
in
Source
Make sure your ID column is in text format - or change the custom function above to:
let
Source = (ID as number) =>
Json.Document(
Web.Contents(
"https://urlthatholdstheinfo.com/",
[
Headers=[Authorization="Bearer "& GetToken()] ,
RelativePath=Text.From(ID)
]
]
)
)
in
Source
I'm fairly sure this problem arises because of the way you're constructing your URL using Text.Combine. Can you rewrite your query to use the RelativePath header
https://learn.microsoft.com/en-us/powerquery-m/web-contents

Getting Error when publishing in azure synapse or azure data factory

I am trying to publish the synapse pipelines from master branch.
And I am getting an error and it does not point it to any details or any specific pipeline or Data flow.
Error is below:-
Error code: OK
Inner error code: BadRequest
Message: Missing parameter definition for Env
BadRequest Message: Missing parameter definition for Env
is a parameter-passing error that occurs often. Default value can't be expressions. It has to be static value.
You can check if you follow the steps passing parameters:
Create parameters in the dataset:
create parameters
Change the dynamic content to reference the new dataset parameters in the dataset
change the dynamic content
Enter dynamic content referencing the original pipeline parameter in the calling pipeline
Enter dynamic content

IBM Watson Clinical Annotator API Python SDK - adding optional parameter throws a 400

I am following the API documents for analyzing text via the API docs here and the examples on github here. When I add the optional parameter to the annotator to get all of the codes like this:
anno_cd = acd.Annotator(
name='concept_detection',
parameters = {'include_optional_fields':'medical_codes'})
I get this:
Error Occurred: Code 400 Message Bad Request CorrelationId
820af2f3-0b25-477a-bde5-20fc57fd4a4d
Does anyone see what I am doing wrong?
It was a problem with the way the parameters were set. You need to build a collection inside a collection. This works:
anno_cd = acd.Annotator(
name='concept_detection',
parameters = {"expanded": ["true"],"include_optional_fields":["medical_codes"]})

How can I pass context params using talend api?

I'm trying to automate talend job executions using the Talend API but I'm getting an error when I try to pass the context params using the api.
The json I'm encoding to 64 is the following:
JSON='{ "actionName":"runTask", "authPass": "TalendPass", "authUser": "name#example.com", "jvmParams": [ "-Xmx256m" , "-Xms64m" ], "contextParams": ["host_mysql_db01": "failed", "database_analytics": "testing.it"],"mode": "synchronous", "taskId": 43}'
Error message:
{"error":"Expected a ',' or ']' at character 172","returnCode":2}
I found another stackoverflow issue Add context parameters to Talend job in Tac via API without actually running it but he doesn't say how he pass it and I cannot reply with a comment asking how he did it
The real talend api call is:
wget -O file http://localhost:8080/org.talend.administrator/metaServlet?$JSON_ENCODED
Can I get some help?
Actually, the json your are passing to the metaservlet is not valid json. You can check it with an online validator like http://jsonlint.com.
You are specifying the contextParams attribute as an array, but that syntax is not valid in json. An array can contain either a list of values (like jvmParams) or objects (which can themselves contain arrays). Here's an example.
Moreover, according to Talend reference, the attribute should be called "context" and must be an object instead of an array, like so:
"context":{"varname1": "varvalue", "varname2": "varvalue2"}

How can I get multiple %-encoded parameters into an apiary URI template?

The ApiaryIO spec—actually the RFC to which it points—indicates that you cannot use "." in a parameter name, you need to encode it to "%2E". That's fine, but there seems to be a bug where Apiary can only handle one such encoding. For example, the following
## Notes Collection [/notes{?foo%2Ebar}]
yields the following Code Example
request = Request('http://private-d1ee7-testingnewapiary.apiary-mock.com/notes?foo.bar=foo.bar')
which is correct. However, the following
## Notes Collection [/notes{?foo%2Ebar,baz%2Ebla}]
yields this Code Example:
request = Request('http://private-d1ee7-testingnewapiary.apiary-mock.com/notes?foo%252Ebar=foo%252Ebar&baz%252Ebla=baz%252Ebla')
Notice how in the first the Code Example you see it has "foo.bar" but in the second example it has "foo%252Ebar", which is incorrect.
The downstream effect here is that the incorrect URI is sent to the API server so the response is malformatted creating an error.
How do I encode many "."-containing parameters on the URI template and still get the proper code examples?
Will adding explicit example values for those parameters help?
For example:
## Notes Collection [/notes{?foo%2Ebar,baz%2Ebla}]
+ Parameters
+ foo%2Ebar (`42`)
+ baz%2Ebla (`24`)
Update
This seems to be a bug in the way the documentation / code samples are rendered. I have created the tracking issue here https://github.com/apiaryio/language-templates/issues/36.