Send custom property with value as JSON array - json

We want to send some events to Application Insights with data showing which features a user owns, and are available for the session. These are variable, and the list of items will probably grow/change as we continue deploying updates. Currently we do this by building a list of properties dynamically at start-up, with values of Available/True.
Since AI fromats each event data as JSON, we thought it would be interesting to send through custom data as JSON so it can be processed in a similar fashion. Having tried to send data as JSON though, we bumped into an issue where AI seems to send through escape characters in the strings:
Eg. if we send a property through with JSON like:
{"Property":[{"Value1"},..]}
It gets saved in AI as:
{\"Property\":[{\"Value1\"},..]} ).
Has anyone successfully sent custom JSON to AI, or is the platform specifically trying to safeguard against such usage? In our case, where we parse the data out in Power BI, it would simplify and speed up a lot some queries by being able to send a JSON array.

AI treats custom properties as strings, you'd have to stringify any json you want to send (and keep it under the length limit for custom property sizes), and then re-parse it on the other side.

Related

Azure FCM NotificationHubClient Configuration for Data Payload?

Using
NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(notificationHubConnection, notificationHubName, enableTestSend);
NotificationOutcome outcome = await hub.SendDirectNotificationAsync(fcmNotification, deviceUri);
I am able to send and receive notifications using FCM via the Azure hub to a Xamarin Android app, finally. However the payload is not present in the received RemoteMessage even though the sent fcmNotification json payload looks good and passes validation. I am basically looking at the RemoteMessage.Data property, but not finding the expected payload array. Looking at RemoteMessage structure, I haven't found any part of the payload array either.
I know that the Azure hub manipulates the notification by adding the necessary headers like content type, e.g. "application/json". Are there any other settings that are needed to be passed to enable the "data" only payload?
Additional settings are not necessary, but the format of the entire notification contents has to have this type of structure:
"{ \"data\":{ \"A\": \"aaa\",\"B\": \"bbb\",\"C\": \"ccc\",\"D\": \"ddd\",\"E\": \"eee\",\"F\": \"fff\"}}"
The number of data elements is up to you. The data element name can be anything as well as the associated content except for the need for backslash usage for special characters. Both the element name and content can be inserted using variables creating a traditional composite string.
What is especially important is the inserted spaces as shown. Also note that traditional Json formatting is not acceptable because of the need for those spaces.

Logic App dynamic content give null or ""

I want to create small automation between Jira and Azure. To do this, I execute HTTP trigger from Jira, which send all request properties to Azure Logic App. In "When a HTTP request is received" step in Logic App I can see properly JSON schema with all data which I need. In next steps for example I want to add user to Azure AD group. And problem starts here.
For example, I want to Initialize variable and set it with value from JSON. I choose properties from dynamic menu, but after script execute always it is null value ( but in first step in "raw output" I see whole schema with data). I tried many things - parse, compose, many different conversion - always without any luck - null value or "".
Expected value - when I want to initialize variable using Properties from Dynamic Content I want to have value from input json.
Output from Jira
Output with the same JSON send from Postman
Thanks for any help !
--
Flow example
Flow result
If you send the json with application/json content-type, you could just select the property with the dynamic content, however if not you have to parse it to json format with Parse Json action.
AS for the schema, you need use your json data to generate it with Use sample payload to generate schema. Paste the sample json payload.
Then you will be able to select property. However you could not implement it dynamic content, you have to write the expression. The format will be like this body('Parse_JSON')['test1'] and if your json has array data, you need to point the index it will be like this body('Parse_JSON')['test2'][0]['test3'].
Below is my test, you could have a try.

Create JSON Object in React.js from Rest Service

I am looking for either guidance or a good example where I can map data coming from rest services to JSON "type" object which can then be used in a number of different react components.
The JSON Object will be used to map data from a few different rest services, which essentially hold very similar data which makes it better to use one object and then to bind the data to the respective React Components.
I am fairly new to React.JS and I have googled around to find a data mapper to JSON from Rest Service example.
Can anyone help?
You typically don't have to do too much, at least on the front end side. As long as the REST endpoint can return JSON responses you'll be fine. Just make sure you set the appropriate Content-Type headers in the request. Note that setting the header doesn't guarantee a JSON response, the server has to be able to send it in that format.
If you're creating the REST service yourself, you have many options. If you're using node, you can simply return a javascript object. If you're using some other language like Java, C#, etc., they come with libraries that can serialize objects into JSON for you. I use JSON.net when working with C#. In these cases, because the data will be returned as a string, you'll just need to JSON.parse() it upon receiving it and then set it to the appropriate React component's state.

Parse APEX RESTful WebService reference JSON response stored in CLOB001 column

I am trying to generate a report page in my APEX application, using the data obtained from a REST service response.
I added a new RESTful webservice reference and sepecified a JSON output.
Then I've generated a query/report page, but this is what's being currently displayed:
Instead I want the report to display the contents of data field on the JSON response (A single row with various columns and values)
Is there any straight forward way to show each response element and field on its row and column instead of a single column and row with the whole response, like there is with XML RESTful responses?
Consider whether another output type may be more handy. If you're putting out JSON and expect to handle it in PLSQL, then you do need to realize that PLSQL does not handle that natively.
Want to handle the rest response as json in plsql? Then look into some PLSQL libraries/projects that may do this:
http://reseau.erasme.org/pl-sql-library-for-JSON?lang=en
http://sourceforge.net/projects/pljson/
Then print out the returned HTML through HTP.P calls.
Though honestly, if you want to stick with plsql you would be much better off using XML as a return type, since you can then use all the xml goodies in the database. Though simply spitting out some html structure may not be quite too interesting (but I digress).
Or call the rest service through an ajax call from javascript, and handle the object there. After all, JSON is Javascript Object Notation and should be perfect for javascript, right? Then simply inject your html somewhere in the document. Ideally you would set up a region as a container for this.

Apigility field accepting an array of embedded objects?

I'd like to create an Apigility REST service which accepts POSTs of, for example, a user object which has a field containing an array of address objects. I can define the field without validators and process the raw JSON in my code, but I'm wondering if there is a better way to do this where the nested objects can also be validated by Apigility?
Apigility has a module called content-validation -- it allows you to configure input filters for your services, and request data will be passed through the input filter for validation and an appropriate ApiProblem response is returned when validation fails. (see https://apigility.org/documentation/api-primer/content-validation)
That still leaves the onus on you to configure an input filter that will suit your needs.
I would check packagist.org for a JSON Schema validator library which can take a JSON schema and a JSON payload and verify that the payload is well formed according to the schema. Then you can easily implement a custom InputFilter and bind it to your services. This will give you validation that the main object and sub objects are well formed (ie: user has name, email, birth date and address field contains objects that all have address/street/zip/etc).