Reply
Posts: 41
Topics: 19
Kudos: 5
Solutions: 1
Registered: ‎10-30-2011
Accepted Solution

Why does authnet endpoint return XML instead of JSON?

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.)


Accepted Solutions
Highlighted
Solution
Accepted by topic author ZeroGravPro
‎04-16-2018 06:24 AM
Posts: 284
Kudos: 47
Solutions: 33
Registered: ‎03-13-2017

Re: Why does authnet endpoint return XML instead of JSON?

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 !!

Follow me at

https://twitter.com/anuragg29

https://www.linkedin.com/in/anuragg



Send feedback at developer_feedback@authorize.net

View solution in original post


All Replies
Highlighted
Solution
Accepted by topic author ZeroGravPro
‎04-16-2018 06:24 AM
Posts: 284
Kudos: 47
Solutions: 33
Registered: ‎03-13-2017

Re: Why does authnet endpoint return XML instead of JSON?

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 !!

Follow me at

https://twitter.com/anuragg29

https://www.linkedin.com/in/anuragg



Send feedback at developer_feedback@authorize.net