I have an attribute which can store 1024 characters in the column of my table in db. Let's assume the name of attribute is statusMessage.
The value of statusMessage attribute in the column of table is:
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
But the json response which I get is instead something like below:
{
"statusCode": "success",
"statusMessage": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..."
}
So my observation is that the db is storing the complete 1024 characters in the column of its table but the JSON response is not able to show the complete data in its response for the given attribute.
What could be the possible reason for this? And how can it be rectified?
Note: Using SQL database and hybris platform for my web application and this scenario is only happening for v1 rest web API's. For v2 rest web API, it renders all 1024 characters.
Related
I am not sure, if I am missing something but unable to find on google as well.
I am looking into some features of Jmeter. I used postman as well.
We have API POST request and it returns JSON response.
While hitting my API from Postman, I am getting 'JSON' response. (i.e. no issues) and API triggers my service.
Now, if hit from Jmeter. Response if 200 and my service trigger too. But in response I am getting some code or key rather JSON values.
Like 'e5e9e97a9ba2144b448c8b150498b5a0'.
Sample HTTP Request:
Thread Name: First_API_Test 1-1
Sample Start: 2019-03-28 15:48:33 IST
Load time: 7608
Connect Time: 0
Latency: 7608
Size in bytes: 492
Sent bytes:0
Headers size in bytes: 127
Body size in bytes: 365
Sample Count: 1
Error Count: 0
Data type ("text"|"bin"|""): text
Response code: 200
Response message: HTTP/1.1 200
HTTPSampleResult fields:
ContentType: application/json;charset=UTF-8
DataEncoding: UTF-8
I tried changing HTTP Header Manager, but no luck.
I tried 'View Result Tree' JSON drop-down, but that was my bad to try because that will work once I get response. I am not getting response at all.
I search google and stackoverflow, but for JSON, everyone talking about handling/validating JSON response using JSON Extractor but for me I am getting JSON response at all.
I tried to store the output but here too I am getting this code stored in generated output file.
....
</requestHeader>
<responseData class="java.lang.String">e5e9e97a9ba2144b448c8b150498b5a0</responseData>
<responseFile class="java.lang.String"></responseFile>
<cookies class="java.lang.String"></cookies>
...
Expected result from Postman is:
{
"outgoingFileId": "25808",
"status": "Generated",
"createdDate": NA,
"reconcileStatus": null,
"failureMessage": NA,
"successMessage": NA,
"executionTS": 1552912975190,
"nextPayload": "{\"presentTS\":1553696530996,\"lastExecution\":1552912975190}"
}
This is caused because in Advanced tab of HTTP Request Save response as MD5 hash? is checked (you want to uncheck it)
Save response as MD5 hash? If this is selected, then the response is not stored in the sample result. Instead, the 32 character MD5 hash of the data is calculated and stored instead. This is intended for testing large amounts of data.
I think. I missed. I was using latest version 5.1.1.r1855137
Under Http request by default option 'Save response MD5 Hash?' was checked.
'un-check' resolved the issue.
Not sure if this was OP's issue, but I had an issue seeing response JSON because I had the dropdown above the request list in my results tree set to "Text". If I change it to "JSON" I can see the results.
Bonjour!
Is there a function for removing/replacing all of a specific character in a JSON in Azure Logic Apps?
I am working with a HTTP request in Azure Logic Apps. The results I would like to see is a unnested JSON as a CSV-file.
My steps looks like this:
1.HTTP GET ->
2.Parse JSON ->
3.CSV-file
The parsed JSON contains alot of nested values which I would like to transform to columns instead.
My idea is to delete the "{" and "}" characters from the JSON before handling it as a CSV-file which I hope will result in success.
A small example of the structure:
"data": [
"consumption_stats": {
"energy": {
"hour": {
"count": 27745,
So my question is: how can I, in Azure Logic Apps, remove/replace these characters before I make it to an CSV-file?
Thank you
There is a replace function built into Logic Apps. You could simply replace the characters with an empty string?
Click "Add Dynamic Content" then go to the expression tree and type "Replace".
Is it the recommended way to pass a JSON string as a parameter value in a REST API?
This is the data which I am trying to send :
http://127.0.0.1:8000/v1/product/?productName=&metrics={"memory":2,"disk_space":10}
Here, is it ok to pass the value of metrics as JSON value?
Initially, I tried passing the metrics JSON value in the body. As it is not supported/recommended standard I have removed it.
Is it the recommended way to pass a JSON string as a parameter value in a REST API?
REST is an architectural style and it doesn't enforce (or even define) any standards for passing JSON string as a parameter value.
If you want to send JSON in the query string, you must URL encode it first:
/v1/products?productName=&metrics=%7B%22memory%22%3A2%2C%22disk_space%22%3A10%7D
Alternativelly, you could redesign the parameters to be like:
/v1/products?productName=&metrics.memory=2&metrics.diskSpace=10
If the URL gets too long (or the query gets too complex to be expressed in the query string), you may want to consider POST instead of GET, and then send the JSON in the request payload:
POST /v1/products/search HTTP/1.1
Host: example.com
Content-Type: application/json
{
"productName": "foo",
"metrics": {
"memory": 2,
"diskSpace": 10
}
}
Sending JSON values in GET request is not recommended. You can do it but metrics json can be long and anybody can read the content.
You should use POST request to send parameters such as productName and metrics in the body.
You should refer to this answer for detailed explanation.
For use Content-Type Application Json Please use below line
request.AddParameter("application/json", "{\n\t\"lastName\":\"gaurav.sablok#agarwalpackers.com\"\n}", ParameterType.RequestBody);
This is used with "RestSharp" name spaces
I'm trying to pass a list of the following objects as query params to a GET call to my Java service:
{
"id": "123456",
"country": "US",
"locale": "en_us"
}
As a url, this would like like
GET endpoint.com/entity?id1=123456&country1=US&locale1=en_us&id2=...
What's the best way to handle this as a service? If I'm passing potentially 15 of these objects, is there a concise way to take in these parameters and convert them to Java objects on the server side?
I imagine with a URL like this, the service controller would have a lot of #QueryParams...
Create the entire dataset as JSON array, e.g.
[
{
"id": "123456",
"country": "US",
"locale": "en_us"
},
{
"id": "7890",
"country": "UK",
"locale": "en_gb"
}
]
base64 encode it and pass it as a parameter, e.g.
GET endpoint.com/entity?set=BASE64_ENCODED_DATASET
then decode on the server and parse the JSON array into Java objects using perhaps Spring Boot.
Based on the valid URL size comment (although 2000 is usable), you could put the data in a header instead, which can be from 8-16kb depending on the server. GETting multiple resources at once is going to involve compromise somewhere in the design.
As Base64 can contain +/= you can url encode it too although I haven't found the need to do this in practice when using this technique in SAML.
Another approach would be to compromise on searching via country and locale specific IDs:
GET endpoint.com/entity/{country}/{locale}/{id_csv}
so you would search like this:
GET endpoint.com/entity/US/en_us/123456,0349,23421
your backend handles (if using Spring) as #PathParam for {country} and {locale} and it splits {id_csv} to get the list of IDs for that country/locale combination.
To get another country/locale search:
GET endpoint.com/entity/UK/en_gb/7890,234,123232
URLs are much smaller but you can't query the entire dataset in one go as you need to query based on country/locale each time.
It looks like your GET is getting multiple resources from the server. I'd consider refactoring to GET 1 resource from the server per GET request. If this causes performance issues, consider using HTTP caching.
I am receiveing data from AWS IoT and the incomming data looks like:
{
"desired": {
"status": "ON",
"Temperature": 4,
},
"reported": {
"status": "ON",
"Temperature": 4
}
}
I have set up a text message alert every time that new data comes in. With the text message I only want to receive the temperature. The current query string is:
SELECT * FROM '$aws/things/MyDashButton/shadow/update'
I am assuming that I have to change the star to Temperature, but when I do the text message I receive is blank. I tried looking through the documentation, but cannot find an answer for this.
EDIT:
If I use
SELECT state.desired.Temperature FROM '$aws/things/MyDashButton/shadow/update'
I get {"Temperature": 4} is there a way just to get the value?
There is no way to just get a value by using only the AWS IoT rule engine.
You can instead write some code in AWS Lambda to send you just the value (or with other cosmetics you desire) via AWS SES. Use the Rule Engine to invoke the Lambda function.