cancel
Showing results for 
Search instead for 
Did you mean: 

Error E00003 - Data at the root level is invalid. Line 1, position 1.

I am attempting to convert my programming to the API. The following is the test JSON that I have prepared:

 

{"merchantAuthentication":{"name":"xxxxxxxx","transactionKey":"xxxxxxxxxxxxxxxx"},"order":{"invoiceNumber":54321,"description":"Test Auth API1"},"payment":{"creditCard":{"expirationDate":1218,"cardNumber":4012888818888}},"amount":139.94,"transactionType":"authCaptureTransaction"}

 

I am using ColdFusion and the parameters I have specified are:

 

<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="Accept-Type" value="application/json" />
<cfhttpparam type="body" value="#Display#">

 

When I send it to the testing endpoint, I get the respose of Error E00003 - Data at the root level is invalid. Line 1, position 1.

 

Any idea what I might be doing wrong?

 

 

jpullam
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

Hi @jpullam,

 

You'll need a little bit more in your JSON string. Right now, the JSON object is not a valid transaction request. You can see more about the fields that are required and the necessary heirarchy at our API Reference Guide. Be sure to click the "Try It" tab to see an actual JSON sample. You can also use that tab to paste in your own JSON to see if it works.

 

In your case, your request needs to look more like this:

 

{
	"createTransactionRequest": {
		"merchantAuthentication": {
			"name": "xxxxxxxx",
			"transactionKey": "xxxxxxxxxxxxxxxx"
		},
		"transactionRequest": {
			"transactionType": "authCaptureTransaction",
			"amount": 139.94,
			"payment": {
				"creditCard": {
					"cardNumber": 4012888818888,
					"expirationDate": 1218
				}
			},
			"order": {
				"invoiceNumber": 54321,
				"description": "Test Auth API1"
			}
		}
	}
}

 

The big change is that everything is in an object at the root that declares what you're trying to do. The most common method is createTransactionRequest, but there are other methods for the other ways you might use our API.

 

The other big change is that order of the elements will matter. The order of the elements needs to match the order in the API Reference, which is the order in which things are listed in our schema.

View solution in original post

Aaron
All Star
5 REPLIES 5

Hi @jpullam,

 

You'll need a little bit more in your JSON string. Right now, the JSON object is not a valid transaction request. You can see more about the fields that are required and the necessary heirarchy at our API Reference Guide. Be sure to click the "Try It" tab to see an actual JSON sample. You can also use that tab to paste in your own JSON to see if it works.

 

In your case, your request needs to look more like this:

 

{
	"createTransactionRequest": {
		"merchantAuthentication": {
			"name": "xxxxxxxx",
			"transactionKey": "xxxxxxxxxxxxxxxx"
		},
		"transactionRequest": {
			"transactionType": "authCaptureTransaction",
			"amount": 139.94,
			"payment": {
				"creditCard": {
					"cardNumber": 4012888818888,
					"expirationDate": 1218
				}
			},
			"order": {
				"invoiceNumber": 54321,
				"description": "Test Auth API1"
			}
		}
	}
}

 

The big change is that everything is in an object at the root that declares what you're trying to do. The most common method is createTransactionRequest, but there are other methods for the other ways you might use our API.

 

The other big change is that order of the elements will matter. The order of the elements needs to match the order in the API Reference, which is the order in which things are listed in our schema.

Aaron
All Star

I had not seen the full functionality of the Try it box, nor did I appreciate that the buttons for XML and JSON allowed me to switch. 

 

After updating my test JSON as directed I managed to get the transaction to be accepted, but when I tried it live I received confusing results. I still saw the E00003 error message but somehow the transaction was accepted, and I also received an email indicating the transaction had been approved. Also, there was some XML in the response, not JSON!

 

As a next step I converted the whole test program to XML and everything worked correctly this time. No error message, proper XML response, approved email, etc. So I plan to take the easier route of using XML for my app. No idea what went wrong with the JSON test program.

 

I think I have a working approach now. Thanx a lot.

Hi @jpullam,

 

The only thing I can think of is that the content-type in your request somehow got messed up so that it wasn't sending "application/json". However, if you've got it working now and want to leave well enough alone, I wouldn't blame you :)

Yes. I was going thru a proxy and I am told that there was a mime type problem. All good now for both JSON and XML.

 

Thanx again.

Authorize.Net schema is defined as:

"transactionRequest": {
			"transactionType": "authCaptureTransaction",
			"amount": 139.94,
			"payment": {
				"creditCard": {
					"cardNumber": 4012888818888,
					"expirationDate": 1218
				}
			}
}

 But JSON object which a client bulds is:

            "transactionRequest": {

                 "amount": 139.94,

                 "payment": {

                          "creditCard": {

                          "cardNumber": 4012888818888,

                          "expirationDate": 1218

                    }

              },

              "transactionType": "authCaptureTransaction"
}

Note that  "transactionType": "authCaptureTransaction" went to last. Since the order of elements in JSON object is different from one in your schema, JSON inpup won't work with Authorize.Net payment gateway.