ADF json expression formatting - azure-data-factory-2

I've been doing this for about 6 hours now, so I'm turning to the crowd.
I am using ADF to move data from and API to a DB. I'm using the REST copy data activity and I need to properly format a json for the body param with two pipeline parameters and an item from a for loop. My json needs to be formatted as such:
"key" : ["value"]
I'm have difficulty understanding how to format the json body. I believe I need to start the whole body using the json expression:
#json('{"foo":"bar"}')
But I am unable to get the pipeline parameters to be properly expressed in the json. This is makes the most sense as far as I understand it and it simply returns what you see when I peek in the input window.
#json('{"foo":["activity('bar').output.value]"}

"key":["#{activity('bar').output.value}"]
Works, but I still believe I should just be able to pass an array!

Related

Vega Visualization where Data Element Name Contains At Symbol

We have data created by an external source (i.e. I cannot just change the names used so it works) -- the datetime field is named #timestamp and I cannot figure out how to address that element within a transformation expression.
Sample data is available on Vega.GitHub.IO and in a Gist with the data -- I added the "timestamp" element to verify the issue I am experiencing is related to the at sign in the name. Using the 'timestamp' data field, I am able to transform and graph the data as desired:
But I have been unable to use the #timestamp field. I get a parse failure if I use "expr": "datetime(datum.#timestamp)" and an invalid date if I use "expr": "datetime('datum.#timestamp')". Attempting to escape the at sign (or the quotes) gives me parse errors as well. How exactly can I use the data element named #timestamp in the expression?
I finally figured this out -- I don't think it has anything to do with Vega but, rather, is a JavaScript limitation. I can use the array subscript method of accessing the data and the dates parse.

Pentaho PDI unable to use parameter in transformation

Using Pentaho PDI 8.3.0
I am unable to use a parameter in a REST call within a transformation. What I've done is:
Create a transformation and given it a parameter called PAGE_NR with default value 1
Create a job
Call the transformation with parameter PAGE_NR = 1
In the transformation, set up a GET request to a REST API.
In the URL field, setup the call like http://myurl.com/foo/bar?page=${PAGE_NR}
When I call this from either SoapUI or a browser it works but it always breaks when running the job. It does not seem to translate this parameter into the value, but instead passes it exactly like mentioned above.
I need this parameter because of calling the same URL but with different results. I don't know the amount of pages up front but take care of that logic later in said transformation.
Working on Linux btw. I have tried different variations of calling the parameter but nothing seems to work.
With the information given in the comments, I am willing to make an educated guess:
The REST Client step does not perform variable substitution on the URL if it comes from a field in the stream. What you can do is insert a Calculator step before the REST step with the operation "Variable substitution on string A" with your URL field as Field A.
This should give you the desired URL with page number.

serilog separate events formatted in json by a comma

i am using serilog in asp net core application and using a json formatter to create a daily log file (rolling interval is set to "Day").
When i look at my file each event is itself valid json but the file in a whole is not which makes looking at it in something like code beautify impractical.
Is there a way to tell the serilog to add a comma between the events so that the file will be valid.
I think you are incorrect when you say that your log file would conform to json if commas separated each line. A valid json document would either start with { and describe an object, or start with [ and describe an array. Either way, you would have to close the document, and only then it would be valid json. Now to the million dollar question: how would you know when to close the document even if you wrote your own text formatter?
I think you should treat each log event as a valid json object, and use a tool and product that supports it.

Endpoints returning BufferInputStream with strange value in Mulesoft Anypoint Studio

I have 3 separate APIs, A, B, and C. A and B are completely independent, whereas C queries A and B to compile data together. Each API is in its own project and running on its own port (8081, 8082, and 8083, respectively).
I am able to successfully hit A and B individually AND through C...sort of. When C hits one of these endpoints, the result comes back as a glassfish.grizzlly.utils.BufferInputStream.
I've dealt with this BufferInputStream type before by using a Transform Message Component. However, doing so here simply produces an error, saying that payload.id is of the wrong type (it should be an integer). When running this in debug mode, I can see that A has an Output Payload with id: Integer (it is of a custom type). However, upon moving back into C's flow, the payload is now the aforementioned BufferInputStream type, and I'm unable to directly access payload.id.
In short: How do I retrieve data in one project from another project?
Thanks in advance!
Update:
I used an Object to String transformer on the BufferInputStream to get a better look at the value. It appears to be in the format of a URL:
id=12345&name=nameValue&otherVal=%5B8499%5D...
I can #[payload.split('&')] at this point and get most of what I need, but then there's still the issue of things like the following:
summary=Words+with+plus+signs+in+the+middle
Again, I can work around this with things like split, but surely this is not what is intended.
Update 2:
I discovered the following warning:
[[test].api-httpListenerConfig.worker.01]
org.mule.module.http.internal.listener.HttpResponseBuilder:
Payload is a Map which will be used to generate an url encoded http body but
Contenty-Type specified is application/java; charset=windows-1252 and not
application/x-www-form-urlencoded
I'm not entirely sure what to do with that info, though the Contenty-Type typo is interesting ^^
Solved! In A and B, I needed to use an Object to Byte Array transformer before returning the value. This allows me to use a Byte Array to Object transformer in C and get the original value back.

T-SQL code for converting nvarchar string to UTF-8 (for URL percent-encoding)

I need to generate an URL string for a SSRS report (in order to link it with our CRM software). The report name is in Hebrew. When I send the URL string (with Heb) to Internet Explorer, it doesn't recognize the address because it isn't encoded with Percent-encoding (BTW, it works fine in Firefox). (Sending a URL with English only does work fine that way.)
Anyway, I tried to perform the encoding. I succeeded converting it to URI with UNICODE characters. I need to get the URI in UTF-8. For example, the letter 'י' should be converted into '%d7%99' and not to '%05%D9'.
I included a link:
A table with the codes, for your use, if needed.
I need the conversion\encoding function for 1 character. I can build the rest of the script / function for the complete string by myself.
I used a script which used the master.sys.fn_varbintohexstr function. As I said, though, the results aren't proper for IE.
the following:
SELECT master.sys.fn_varbintohexstr((CAST (N'י' AS varbinary)))
will get 0xd905, which I formatted into percent encoding. I should get 'd7 99' instead.
wrap up:
I convert an Hebrew character into URI percent encoding. I get a unicode result. I wish > to get a utf8 result.
Input = 'י'. Current output = %d9. Wanted output = %d7%99
How can I get those results?
I have had to deal with a few similar problems and there are two approaches that you may wish to consider; the first is to transform your data into HTML in the query and then render the result as HTML in the RDL, the second is to use JQuery to identify those cells with the incorrect value on the client and then transform that cell (again, using JQuery). The benefit of the second option is that if the server rendering is working on Firefox the transformation overhead doesn't get invoked. The downside is that if you are not rendering the report as HTML it won't work.
For the first option, in the select statement you would need to alter the appropriate column to produce a nvarchar value that looks like
<span style="font=yourfont;" charset="UTF-8">linkname</span>
With that string as data you then assign that to the appropriate columns (or cells, as needed)
In the RDL designer drag a placeholder for your field onto the designer and right click the placeholder and select placeholder properties then you can select to display the content as HTML.