In my custom PHP libs I have my Accept.js integrations working perfectly. I use very stripped-down calls, not the bloated authnet SDKs. I send XML to the endpoint (https://apitest.authorize.net/xml/v1/request.api), and I get back JSON, and my client-side js is able to parse the json and all is good.
Here's the problem: Now I'm trying to do the same thing with .NET (c#) instead of PHP, for a different client. The Accept.js works fine (it's the same as with PHP, still on client), and even the .NET works fine and succeeds the transaction BUT I get back XML instead of JSON from authnet. All my client-side js logic is built around json structures so I'd love to keep using that and not have to rewrite it all to parse and examine returned XML.
In summary: In my .NET calls I still want to send in XML, but I want to get back JSON in the response, as happens with my PHP calls.
I have compared my php calls and my .NET calls, and while the plumbing is different, the basic stuff seems to be all the same. I can't find any parameter or flag or indicator that says "get back JSON" or "get back XML".
How can I tell authnet api endpoint to return JSON instead of XML in my call to (for example) createTransactionRequest? Thanks in advance.
(Note: There's a newtonsoft lib that converts xml to json, and I got that to work, but the result is very different compared to the json that authnet sends pack, so the js json parsing all breaks.)
Solved! Go to Solution.
04-14-2018 04:23 PM
Hi @ZeroGravPro
For json you need to pass the Content-Type header as application/json in your request .
HTTP Request Method: POST
Sandbox API Endpoint: https://apitest.authorize.net/xml/v1/request.api
Production API Endpoint: https://api.authorize.net/xml/v1/request.api
XML Content-Type: text/xml
JSON Content-Type: application/json
API Schema (XSD): https://api.authorize.net/xml/v1/schema/AnetApiSchema.xsd
Hope it helps !!
04-15-2018 01:19 PM
Hi @ZeroGravPro
For json you need to pass the Content-Type header as application/json in your request .
HTTP Request Method: POST
Sandbox API Endpoint: https://apitest.authorize.net/xml/v1/request.api
Production API Endpoint: https://api.authorize.net/xml/v1/request.api
XML Content-Type: text/xml
JSON Content-Type: application/json
API Schema (XSD): https://api.authorize.net/xml/v1/schema/AnetApiSchema.xsd
Hope it helps !!
04-15-2018 01:19 PM