Azure Logic App and Data Flow - Remove ? and # from JSON (XML) - azure-logic-apps

I have created a Logic App that converts XML to JSON
LogicAppProcess
This work 'great', no issues in that part of the process - however, this retains some ? and # symbols within some of the column names. This is then not working downstream in an Azure Data Flow as the # symbol is being picked up a parameter..
enter image description here
{"code":"BadRequest","message":"ErrorCode=InvalidTemplate, ErrorMessage=Unable to parse expression 'version'","target":"pipeline/PL_XXXX/runid/XXXX","details":null,"error":null}
Any ideas as to how i can either replace the ? and # symbols at the first point in the process (Logic App) or accommodate for these in the Data Flow?
This is how the Data Flow code sees the error in the Script element - the ?xml is not throwing an error but the first # is, and shows #version as the error
"script": "source(output(\n\t\t{?xml} as ({#version} as string, {#encoding} as string),\n\t\trss as ({#version} as string, {#xmlns:cisAbstract} as string...

You can use the replace() function in your logic app to replace the ? and # with null string "". If your data is not string type(such as json object or array or any other type), you can use string() function to convert them to string first and then do the replace() function. Shown as below expression:
replace(replace(string(<your data>), '#', ''), '?', '')

Related

CakePHP slug converting my Bangla text to English

I am trying to save category name after convert in slug
So in entity I have used setter for convert my text to slug text
protected function _setName($name)
{
return Text::slug($name);
}
After send post request in input name "আমি তোমায় ভালোবাসি"
Has got in database
ami-tomaya-bhalobasi
After make transliteratorId false
return Text::slug($name,[
'transliteratorId' => false
]);
I got output : আম-ত-ম-য-ভ-ল-ব-স
My expected result is
আমি-তোমায়-ভালোবাসি
How can I get my desire result ?
The whole point of slugs is to obtain a "safe" pure US-ASCII string. If all you seemingly want is to remove white spaces you can use a simple regular expression:
preg_replace('/\s/u', '-', 'আমি তোমায় ভালোবাসি')
However, I recommend you double-check why you think this is necessary in the first place. A properly encoded URL would display spaces as %20 anyway, which is "ugly" in a Latin script text but will get unnoticed in other scripts:
var_dump(rawurlencode('আমি তোমায় ভালোবাসি'));
string(159) "%E0%A6%86%E0%A6%AE%E0%A6%BF%20%E0%A6%A4%E0%A7%8B%E0%A6%AE%E0%A6%BE%E0%A6%AF%E0%A6%BC%20%E0%A6%AD%E0%A6%BE%E0%A6%B2%E0%A7%8B%E0%A6%AC%E0%A6%BE%E0%A6%B8%E0%A6%BF"

Jmeter tool create request..cannot handle array parameters and dynamically created parameters

I'm having 2 issues when trying to do the create api requests using the jmeter tool
1). How to handle an array parameter. "Versions": "$[Versions]"
getting the following error message
{"timestamp":"2020-02-14T07:18:33.720+0000","status":400,"error":"Bad
Request","message":"JSON parse error: Cannot deserialize instance of
java.util.ArrayList<java.lang.Object> out of VALUE_STRING token;
nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
deserialize instance of java.util.ArrayList<java.lang.Object> out of
VALUE_STRING token\n at [Source: (PushbackInputStream); line: 15,
column: 22]
2). how to handle dynamically created time stamp parameter createtime: "${createtime}"
getting the following error message
{"timestamp":"2020-02-14T07:17:58.942+0000","status":400,"error":"Bad
Request","message":"JSON parse error: Cannot deserialize value of type
java.time.OffsetDateTime from String \"${factoryCompleteTime}\":
Failed to deserialize java.time.OffsetDateTime:
(java.time.format.DateTimeParseException) Text
'${factoryCompleteTime}' could not be parsed at index 0; nested
exception is
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot
deserialize value of type java.time.OffsetDateTime from String
\"${factoryCompleteTime}\": Failed to deserialize
java.time.OffsetDateTime: (java.time.format.DateTimeParseException)
Text '${factoryCompleteTime}' could not be parsed at index 0\n at
[Source: (PushbackInputStream); line: 15, column: 24]
My json body looks like this.
"Versions": "$[Versions]",
"createtime": "${createtime}"
I think you should pass this Versions a little bit differently, for example if it should be a JSON Array it should look like:
"Versions": [${Versions}],
or
"Versions": ${Versions},
It appears that your ${factoryCompleteTime} variable doesn't have a value so it has been replaced by the default placeholder. Use Debug Sampler and View Results Tree listener combination in order to check the variable value, it should be in format of the OffsetDateTime to wit something like: 2007-12-03T10:15:30+01:00

JMeter - converting File to String to Array

I need to do the following:
Read a .csv file into a variable. Csv file is having one single row with a string like (110,111,112,113,114)
Using this String variable, split the content on the basis of a comma",".
What I have done:
I have added a Thread Group
2a. Added a user defined variable 'Config Element'.
2b. Added a variable named 'issueIds' having value ${__FileToString(D:\TestCasesId.csv,,issueIds)}
3a. Now I added a JSR223 Sampler with the following code:
String lineItems1 = ${issueIds};
log.info(lineItems1);
3b. Executing this give the following error:
Response code:500
Response message:javax.script.ScriptException: In file: inline evaluation of: ``String lineItems1 = 114660,114661,114662,114663; log.info(lineItems1); ;'' Encountered "114661" at line 1, column 28.
in inline evaluation of: ``String lineItems1 = 114660,114661,114662,114663; log.info(lineItems1); ;'' at line number 1
4a. Added a BeanShell Sampler with the following script:
String lineItems2 = ${issueIds};
String[] lineItems2Arr = lineItems2.split(",");
log.info(lineItems2);
log.info(lineItems2Arr[0]);
4b. Executing this give the following error:
Response code:500
Response message:org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``String lineItems2 = 114660,114661,114662,114663; String[] lineItems2Arr = lineIt . . . '' Encountered "114661" at line 1, column 28.
What am i doing wrong?
You are doing 2 things wrong:
Inlining JMeter Functions or Variables into scripting elements is not recommended, you should be using vars shorthand to JMeterVariables class instance instead like:
String lineItems1 = vars.get("issueIds");
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting therefore consider choosing groovy from the language drop-down
Groovy has much better performance comparing to Beanshell, it supports all modern Java SDK features and provides some syntax sugar on top of it, check out Apache Groovy - Why and How You Should Use It article for more details.
In case amount of comma separated fields is the same for all used csv files, you can consider using 'CSV Data Set Config' instead of manual splitting. In that case you will have a separate variable for each column in the csv, e.g.
id1,id2,id3,id4,id5
110,111,112,113,114

How to handle % and # characters with next-routes

I am using next-routes and my application URL need to receive parameter as name that contains % and # characters. For example, "C#", "100%" etc.
So its URL will look like below.
https://myapp.com/name/C#
https://myapp.com/name/100%
https://myapp.com/name/harry_potter
For "C#", I have found that query value from the getInitialProps function will be "C" only (# character is cut)
and for "100%", I have found that next-routes return error as below. URI malformed has occurred on decodeURIComponent function because of % character.
https://user-images.githubusercontent.com/18202926/48536863-659f6d00-e8e2-11e8-8c64-a0180b51e921.png
If I need to handle both of characters, could you please suggest how can I handle them by using next-routes?
NB. I opened the issue on next-routes here
You will have to encode the URI component so that the special characters are not used.
if you must get C# it would be encoded as "C%23"
100% would be "100%25" and so forth.
use the encodeURIComponent() function to generate the appropriate URI.
Hope it helps.
refer if needed : escaping special character in a url

BadArgumentError: Expected an instance or iterable of (<type 'int'>, <type 'long'>); received idofOne (a str)

I keep getting the following error :
BadArgumentError: Expected an instance or iterable of (, ); received idofOne (a str).
and have tried to convert to int() but then get a different error saying :
ValueError: invalid literal for int() with base 10: ''
What is going on? I'm using Google App Engine - and retrieving the idofOne from the html template. It is the ID representation using jinja -- and it is showing a value of "1" - so it shouldn't be empty - any suggestions???
class makeHeadings3(Handler):
def get(self):
self.render('new_entries/ADMIN_make_headings3.html')
def post(self):
idofOne = self.request.get("idofOne")
type2=self.request.get("type2")
heading2name = self.request.get("headingTwo")
description2 = self.request.get("descriptionTwo")
heading3 = self.request.get("headingThree")
#getting relevant level 1 entry by id
level_1_info=Level_1_Headings.get_by_id(idofOne)
Actually - I changed the value coming from my template from the id() to the key(). However I'm discovering that in my template from which I'm retrieving the value from is coming back empty string "". why? I see the value of the key in teh template and I'm retrieving with the correct name "keyofOne" so why is it coming back empty back to my python server code???
Key for Category Level 1
DO NOT EDIT
You could first check:
level_1_info=Level_1_Headings.get_by_id("1")
Then need to add debug in your code to see what value is returned by "idofOne"
import logging
# snip
logging.info("type "+type(idofOne))
logging.info("value "+idofOne)
I hope this helps
The below should fix it. You need to get the integer value of that id
idofOne = int(self.request.get("idofOne"))
Always when parsing post or get parameters you have to convert them to the correct type before passing them to the datastore query.

Resources