We have to talk to a Microsoft Dynamics 365 Api. When calling an custom action we retrieve a json as in the example below
{
"#odata.context": "just-a-domain",
"ids": "[{\"account\":\"whatever_id\",\"name\":\"test 2\"}]"
}
As you see the value of ids comes as string, but it should be json. Is there any restrictions for the return values in Dynamics 365?
The expected output should be like
{
"#odata.context": "just-a-domain",
"ids": [
{
"account": "whatever_id",
"name": "test 2"
}
]
}
Didn't find anything about it in the documentation. But the guy who's implementing the custom actions claims it is not possible to do it in any other way.
These are the data types supported in Custom action output parameter:
That being said, JSON is not the straight supported Output param type, but you can ask your CRM developer to give you back some fixed format anyway.
Simply serialized JSON in String Output type, EntityCollection Or Entity types may help you if I understand your need correctly. Read more
Related
I trying to use InvokeHttpProcessor in Apache NiFi to perform POST request with complex JSON body.
Accordingly this tutorial: http://www.tomaszezula.com/2016/10/30/nifi-and-http-post-configuration
I know how to use UpdateAttribute processor to add name/value pairs and then apply an additional transformation via AttributesToJSON.
But how to deal with complex JSON?
For example I have to perform request to GoogleAnalytics reporting API, so I need to perform this request:
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
{
"reportRequests":
[
{
"viewId": "XXXX",
"dateRanges": [{"startDate": "2014-11-01", "endDate": "2014-11-30"}],
"metrics": [{"expression": "ga:users"}]
}
]
}
any ideas?
You can use the GenerateFlowFile and ReplaceText processors to provide a template as the flowfile content and then populate the actual values. Once that JSON object is formed as flowfile content, it should be easy to send it via POST using InvokeHTTP
When using Box.Com APi, Add Collaboration method (https://developers.box.com/docs/#collaborations-add-a-collaboration) there's a parameter that states that its type is object (the accessible_by parameter). This is an example of something that is actually all over the documentation.
Reading the documentation, seems to me that these are objects in mini format, but they don't state the type.
Here is the object format for the accessible_by parameter used in the Create Collaboration endpoint:
"accessible_by": { "id": "USER_ID", "type": "user" }
Anyone know how to customize the names asp.net webapi returns? I'm really interested in changing "odata.count" to be something like "odata-count" - the dot is messing up Infragistics IgniteUI controls.
Example URL: http://localhost/odata/users?$inlineCount=allpages&$top=10
Example oData:
{
"odata.metadata":"http://mydomain/odata/$metadata#Users",
"odata.count":"3",
"value":[
{"FirstName":"Alan","MiddleName":"A.","LastName":"Arlington"},
{"FirstName":"Brad","MiddleName":"B.","LastName":"Boston"},
{"FirstName":"Dirk","MiddleName":"J.","LastName":"Watkins"}
]
}
I could also live with putting all oData metadata in a separate top-level object like:
{
"odata":{
"metadata":"http://mydomain/odata/$metadata#Users",
"count":"3",
},
"value":[
{"FirstName":"Alan","MiddleName":"A.","LastName":"Arlington"},
{"FirstName":"Brad","MiddleName":"B.","LastName":"Boston"},
{"FirstName":"Dirk","MiddleName":"J.","LastName":"Watkins"}
]
}
OData protocol defines a standard representation for OData requests and responses in JSON format. The metadata key names like odata.count are defined by the spec and are not configurable to improv inter-operability with standard clients.
In short, you cannot customize those names.
I have an ASP.NET Web API project, and I want to use oData filters in the project, with the ASP.NET oData preview package. This means I need to use IQueryable as the response type.
Unfortunately, the consumer requires the response wrapped like so:
{
"total": 2,
"success": true,
"data": [
{ object1 },
{ object2 } ]
}
I created a wrapper object which assigns the IQueryable response from my original version to the "data" property, and sets the values for the "total" and "success" properties as well. This creates the JSON response the consumer is looking for. But it's no longer IQueryable, which means I can't implement oData filters.
I was hoping to take my wrapper object and make it implement IQueryable by setting its enumerators, etc. However, I don't think this will work because I have to assign the Provider and Expression properties to implement the interface, and I don't know what I should put there. I'm using a Repository pattern with IoC, and the EntityFramework Code First data access is in a separate project, with concrete objects assigned to the interface placeholders using Ninject. Perhaps I can abstract out the interfaces all the way from the data access layer so that the the Repository objects carry a reference to an IQueryProvider. Do you think this would work, and allow it to support the automated oData integration?
Here's how you do it. Behind the scenes, [Queryable] just creates an instance of ODataQueryOptions and then applies it to the queryable you return. The good news is that you can parameter bind ODataQueryOptions and have code that looks like this:
public Wrapper<MyObject> Get(ODataQueryOptions<MyObject> queryOptions)
{
IQueryable<MyObject> queryResults = queryOptions.ApplyTo(dbSet);
return Wrap(queryResults);
}
You don't even need [Queryable] anymore because you're doing what it would have done for you. Hope that helps.
Using the WCF Data Services Toolkit, or the other ways to support the $format param such as JSONPSupportInspectorAttribute I am getting some json responses that are a little odd to me.
Why does my json look like:
{
"d" : {
"results": [
{
"__metadata": {
When the json from OData.org $format is as follows:
{
"d" : [
{
"__metadata": {
Why does mine have an extra "results" sub section?
My data service is just built directly onto my entity framework model. Do I have to use a specific context template for this to go away?
This is versioning. In V2 we added the server driven paging and inline count features which need to store additional metadata on the feed. But since the feed in V1 was just a JSON array, there was no place to put such metadata.
So in V2 all feeds in responses are wrapped in "results" wrapper. That is the feed is a JSON object which has a property called "results" which has the array. There might be additional properties on the feed object (next link, count, ...).
The versioning of the payload is based on the minimum version required by any feature in that payload. So if your service is using something which requires payload of version higher than V1, the entire payload will be written using that higher version.
You can see this even on the odata.org service - try this:
http://services.odata.org/OData/OData.svc/Products?$inlinecount=allpages&$format=json
The response will be V2 and will use the results wrapper.