Showing results for 
Search instead for 
Did you mean: 

cfhttp with JSON error message - invalid child element 'name'

I am using Accept.js. Attempting to POST createTransactionRequest. I keep getting the errror:


The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'name' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'mobileDeviceId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.


I've carefully checked my JSON and I believe it's correct. Here's my code:


<!--- Create the transaction request --->
<cfset var transRequest = StructNew()>
    transRequest = {
        "createTransactionRequest": {
            "merchantAuthentication": {
            "transactionRequest": {
                "payment": {
                    "opaqueData": {
<cfset transRequestJSON = SerializeJSON(transRequest)>
<cfhttp url="#AN_URL#" method="post" result="postResult" timeout="30">
    <cfhttpparam type="header" name="Content-Type" value="application/json" />
    <cfhttpparam type="body" value="#transRequestJSON#">
<cfset var postResultJSON=DeserializeJSON(postResult.FileContent)>
<cfdump var="#postResultJSON#">
'mobileDeviceId' Isn't even in createTransactionRequest.
What is going wrong?



I'm trying this with Postman and gettting the same results.


POST to:

Body: "raw", "JSON"



    "createTransactionRequest": {
          "merchantAuthentication": {
          "transactionKey": "xxxxxxxxxxxxxxxx",
          "name": "xxxxxxxxxxxx"
        "refId": "FE3-839F030E27EEE7A4",
        "transactionRequest": {
            "payment": {
                "opaqueData": {
                    "dataDescriptor": "COMMON.ACCEPT.INAPP.PAYMENT",
                    "dataValue": "eyJ0b2tlbiI6Ijk1ODg5NDEzMDU4NzY5NDE5MDQ2MDIiLCJ2IjoiMS4xIn0="
            "amount": 10,
            "transactionType": "authCaptureTransaction"


Same result:

    "messages": {
        "message": [
                "text""The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'name' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'mobileDeviceId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."


Interesting. I changed the request to use XML (with Postman). And it works.


So, it would appear I am doing something wrong with JSON. (?)

With JSON, it will fail with that error message just by having the "name" and "transactionKey" in the wrong order. Try:

"createTransactionRequest": {
"merchantAuthentication": {
"name": "API_Login",
"transactionKey": "Transaction_key"



Powered by -
Certified developers

I had seen comments about JSON order in other threads. I changed the order to match. Same result.