I am using CAS 3.5.2. I am trying to call the serviceValidate in CAS passing the "ticket","service" and "format=JSON"(optional parameter). As per CAS 3.0 spec the format parameter specifies the format in which the response will be returned. But even after specifying the format as JSON, i am still getting XML response.
That behavior is not supported in cas 3.5
Related
We are migrating a .NET 2.2 app to .NET 6, and we are facing a problem where some third-party apps that make requests to our system without specifying the Accept HTTP header were getting back JSON data by default in .NET 2.2, but now they are getting XML when nothing is specified.
If I run the same request, but specify Accept as application/json, I get back JSON.
Our app returns 99% of the results in JSON, but has a specific SOAP endpoint that returns XML (it communicates with another SOAP web service and returns SOAP on this single endpoint).
The config is:
services.AddSoapCore();
services
.AddMvc()
.AddXmlSerializerFormatters()
.AddNewtonsoftJson(options => options.SerializerSettings.Converters.Add(new StringEnumConverter()));
If I remove AddXmlSerializerFormatters(), the endpoint returns JSON correctly but then the SOAP endpoint stops working.
I am aware I can use the [Produces] attribute, but ideally we would keep the same default behavior instead of having to manually go through all endpoints.
Is there a way to configure the app to return JSON by default when nothing is specified, without removing XML support?
Asp.NET Core chooses registered formatters by their precedence and the order they added will be their precedence. So as you added XML formatter first, when no Accept header is appeared in request the first matched formatter will be XML formatter. Just add JSON formatter first.
I reproduced the issue and adding JSON formatter first, successfully fixed the problem
builder.Services
.AddMvc()
.AddNewtonsoftJson(options => options.SerializerSettings.Converters.Add(new StringEnumConverter()))
.AddXmlSerializerFormatters();
I am using Postman to query a Dynamics 365 Business Central (BC) API. The API is returning XML and I am trying to get it to return JSON. The Microsoft page that gives an example shows the response as being in JSON format.
I tried added my own Request header to denote that I would like JSON returned
Postman says that by adding my own "Accept" Request header it will override the one that is auto-generated
Even so I tried sending the request with the auto-generated "Accept" header disabled and enabled. This is the response ...
Am I requesting JSON the proper way for a REST endpoint? Microsoft's example seems to indicate that JSON can be returned yet I am only able to get XML back as shown below (just a fragment)
There are two different endpoints you are talking about, $metadata which generates the whole CSDL schema in xml format, whereas <endpoint>/companies fetches the data in JSON format.
This can be tested in browser simply pasting these URLs.
https://api.businesscentral.dynamics.com/v2.0/environment name/api/v2.0/$metadata
https://api.businesscentral.dynamics.com/v2.0/environment name/api/v2.0/companies
Note: Pls test it. I don’t have experience with Dynamics BC, but I managed to get these from docs with the idea of my Dynamics CRM experience :)
Correct me if I am wrong. But microsoft dynamics uses both SOAP and Rest call, seems like you need to use Dynamics Odata APIs
You can go through this doc to understand dynamics Odata APIs :- https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/odata
Im working on a simple subscription on contextBroker, and I'm subscribing my node application.
subscribeContext
After that it returns 200 status OK, and it insert the row in mongo, orion db.
The problem is the field in collection csubs format is "XML", and on the my node application when I log the body that contextBroker sends it logs this
logs from node that is subscribed
Empty body. Then when I change the format in mongo to be "JSON" everything works fine. The body returns the data from contextBroker.
My question is, how to make contextBroker to insert default "JSON" in the format field.
UPDATE:
Version of contextBroker is 0.26.1
UPDATE
Here I tried with attributeFormat=object to make it insert "JSON" in the format field, but it's still "XML"
Orion Context Broker choses the encoding of notifications based on the encoding used for the response of the subscribe context operation associated to such notifications. Note that in this case, the response is in XML so you are getting notifications in XML.
I guess that you are getting XML in the response because Accept HTTP header is not being used in the subscribe context request, which implicitely is Acccept: */*, meaning that the client has not preference regarding encoding. In this situation, Orion choses XML (due to legacy reasons to mantain backward compatibility with old Orion versions that only support XML).
Thus, there are two possible solutions to this situation:
(Recommended) Include Accept: application/json in the subscribe context request.
Add ?notifyFormat=json to "force" notifications to be send in JSON (e.g. POST /v1/subscribeContext?notifyFormat=json), no matter the encoding used for the response to the subscribe context operation.
Side-note: ONTIMEINTERVAL subscriptions (the one shown in your screenshot) have been deprecated. Thus, you are encouraged to stop using them, using ONCHANGE instead.
I have WSO2 API Manager configured and everything seems to work fine.
The only issues bothering me is that in case of an Auth exception, the API manager always returns the response with XML content type, e.g.,
<ams:fault xmlns:ams="http://wso2.org/apimanager/security"><ams:code>900904</ams:code><ams:message>Access Token Inactive</ams:message><ams:description>Access failure for API: /exchange, version: 1.0 with key: 1139a466ebfd825aca953ad7259b9f45</ams:description></ams:fault>
In case of client communicates with my web service with JSON format, the XML response will look a little bit strange.
Is there any ideas how to make API Manager provide error response in JSON format?
This has been addressed in recent versions of API Manager. Auth errors can be set to json format by adding or updating the error_message_type property in WSO2HOME/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler_.xml:
<property name="error_message_type" value="application/json"/>
I've found this also requires JSONBuilder and JSONMessageFormatter to be selected for the json content type in axis2.xml (which is the default setting).
For older versions, this article explains how to manually do the same.
Ok so I have a WCF ODATA service hosted locally for testing purposes. Then I have a Kendo Grid trying to query the service using a Kendo Datasource configured for ODATA exactly like the demo!
On the deployed service, I also implemented the "JSONPSupportBehavior" attribute and class that everyone is talking about!
Still I get this in Fiddler : A supported MIME type could not be found that matches the acceptable MIME types for the request. The supported type(s) 'application/atom+xml;type=feed, application/atom+xml, application/json;odata=verbose' do not match any of the acceptable MIME types 'application/json'
Is this IIS issue now or something else? This is driving me crazy!
This is a change made in the WCF Data Services release. In order to get JSON response back (or JSONP) you need to send Accept header with value application/json;odata=verbose. Pure "application/json" is now reserved for the soon to be coming JSON Light format.
See http://blogs.msdn.com/b/astoriateam/archive/2012/04/11/what-happened-to-application-json-in-wcf-ds-5-0.aspx for more details.