Playframework - ISO format date with timezone in request query param is incorrectly parsed - scala

Why the following iso format date is parsed incorrectly?
GET /find?account.create_date=2016-06-01T00:00:00.000+05:45
In the controller, if I print the queryString, I get the following result:
println(request.queryString)
//result - Map(account.create_date -> Buffer(2016-06-01T00:00:00.000 05:45))
As, you can see, the timezone sign is missing 05:45 instead of +05:45. However, negative timezone work well. 2016-06-01T00:00:00.000-05:45 is successfully parsed as it is.

This is because the ISO date format is not compliant with the URL encoding (RCF-3896 which has a special use for space and : characters). Playframework will be automatically URL decoding the querystrings you pass in the URL for you.
The correct date time string should have been
GET /find?account.create_date=2016-06-01T00%3A00%3A00.000%2B05%3A45
You can read more about the URL encoding here: https://en.wikipedia.org/wiki/Percent-encoding

Related

Data Factory: How to pass JSON as text to Web Body

I have to pass multiple records from a SQL source to the body of a web call in Data Factory in JSON format.
eg.
{"EmployeeCode":"1234",""FirstName":"Joe","LastName":"Bloggs"}
{"EmployeeCode":"5678",""FirstName":"Jack","LastName":"Ryan"}
However, I cannot seem to do it without ADF adding escape characters "\".
{\\"EmployeeCode\\":\\"1234\\",\\"\\"FirstName\\":\\"Joe\\",\\"LastName\\":\\"Bloggs\\"}"
So far I have tried:
Copy activity - Formatted SQL as JSON
Copy activity - SQL output to BLOB JSON
Copy activity - SQL concatenated string output
Does anyone have a process by which to achieve this? I am hoping I have missed something easy.
Thanks in advance....
Escape character backslash \ appears wherever double quotes " are used in the string in the Azure data factory.
Thank you #GregGalloway for your valuable input in the comments sections. As #GregGalloway mentioned, convert the string to JSON format in the web body as shown in the below example.
Example:
Source: SQL data
Getting SQL records using lookup activity.
Passing the output record to web activity in JSON format.
#json(activity('Lookup1').output.value[0].description)
The input of the web activity body is shown as below in JSON format:

How to parse json in dart

I am receiving json string through an API from a website. However, the json format sent to me is not the format i want to work with. I want to change the received json string format to the desirable format.
This is the format i received:
{"symbols_returned":147,"base":"USD","data":{"AED":
3.673010,"AFN":75.392000,"ALL":109.685000}}
This however is the format i desire to have:
{"symbols_returned":147,"base":"USD","data":{"AED":"3.673010","AFN":"75.392000","ALL":"109.685000"}}
The difference between the former and latter is the presence of quotation marks on all the numeric currency values in the second json string. It can be seen that the first json string does not have quotes on the numeric currency values.
My question is how can i programmatically turn the first json string to the second json string format using dart programming language. Any help will be appreciated. Thanks
you need to parse the json data before you can use it.
you need to use the json package from dart:convert do do this
import 'dart:convert';
final yourResult = json.decode(API_RESULT);
print(yourResult) // {"symbols_returned":147,"base":"USD","data":{"AED":"3.673010","AFN":"75.392000","ALL":"109.685000"}}
will parse the json and preserve the data types and make that a Map

In Jmeter how to pass Date as String/text

I need to pass a date (12/12/2016) as a Text parameter to a Post request.
It picks %2f instead of '/'. how do i pass this as string with date having slash.
I tried to send date value as Text/string in parameters tab. whether I select/unselect Encode? parameter, sending by encoding the date value.
Keeping the value in Body Data section worked for me.
So, try by moving all the Post data into Body Data section instead of Parameters section.

Should a date in a REST-response be localized or more of a universal representation?

REST is supposed to deliver readable information to the client. So for a single date (without the time portion) I would expect something similar to this:
"birthday": "12th august 1980" or maybe germanized "12. August 1980"
However this would cause trouble when sending the english representation back to the server with a german locale set. So in the case of a date, wouldn't a more general representation be useful? e.g. 1980-08-12 which could be transformed by the client application to regain readability.
Yes, use the international representation of the date to avoid problems.

PayPal Rest API date filtering not working. What am I doing wrong?

I am using the ruby paypal rest api and everything I do seems to be right but PayPal keeps saying my date format is incorrect.
Here is my call:
Payment.all(:start_time => '2013-03-06T11:00:00Z', :end_time => '2013-03-06T11:00:00Z')
After many attempts I literally took the date example in the documentation: https://developer.paypal.com/webapps/developer/docs/api/
Because no matter what I do I keep getting the same response:
'{"name":"VALIDATION_ERROR","details":[{"field":"start_time","issue":"Must
be a date_time string of form yyyy-mm-ddThh:mm:ss(.sss)?Z"},{"field":"end_time","issue":"Must
be a date_time string of form yyyy-mm-ddThh:mm:ss(.sss)?Z"}],"message":"Invalid
request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"dcd8a9ce6a5e7"}'
Am I blind or does it not make sense?
Looks like it's a bug in our API where it's expecting raw value rather than url encoded value. The SDK was always url encoding the value of the start_time and end_time (or as a matter of fact all url parameters as per the HTTP spec). We have filed a bug and get this fixed as soon as possible. Meanwhile if this is something you need to work, we can possibly make the SDK not url encode the params or you can just modify the code for now locally.
I think your issue might be that you're setting both the start time and the end time to the same exact value. If you want a single day's worth of transactions the end time would be 2013-03-06T23:59:59Z.