Skip to main content
Solved

REST API - Vendor Profile Update Issue

  • June 18, 2023
  • 5 replies
  • 329 views

9001
Freshman I

Hi Connections

I'm attempting to use an API to update vendor info like primary contacts and account addresses. Except for the vendor name, the application's other data fields are not updated. Please use the payload shown below as a guide.  

 

{
    "VendorID": {
        "value": "V00001"
    },
    "VendorName": {
        "value": "SSCI Energy Sdn Bhd"
    },
    "Name": {
        "value": "Robert"
    },
    "Email": {
        "value": "robert@sscienergy.com.my"
    }
}

 

Thanks 

Ram 

Best answer by Vignesh Ponnusamy

@9001,

Primary contact and account address are a part of the default endpoint. Below are the details,

  • PrimaryContact is mapped to the PrimaryContact entity of the Vendor entity
  • Account Address is mapped to the MainContact->Address of the Vendor entity

Below is the screenshot and marking of the entities and few contact fields for your reference,

So to expand these entities, you can try the following,

<<Acumatica URL>>/entity/Default/22.200.001/Vendor?$filter=VendorID eq 'AASERVICES'&$expand=PrimaryContact,MainContact/Address

 

To add/update values to their field you can try the following payload structure,

{
"VendorID": {
"value": "AASERVICES"
},
"MainContact": {
"Address": {
"AddressLine1": {
"value": "Line 1"
},
"AddressLine2": {
"value": "Line 2"
},
"City": {
"value": "Montreal"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "30042"
},
"State": {
"value": "GA"
}
}
},
"PrimaryContact": {
"FirstName": {
"value": "FirstName"
},
"LastName": {
"value": "LastName"
},
"Email": {
"value": "EMailTest@test.com"
},
"Phone1Type": {
"value": "Business 1"
},
"Phone1": {
"value": "789"
},
"Phone2Type": {
"value": "Business 1"
},
"Phone2": {
"value": "123"
}
}
}

Hope that helps.!

Good Luck, feel free to post if you have follow-up questions

5 replies

dcomerford
Captain II
Forum|alt.badge.img+15
  • Captain II
  • June 18, 2023

You should look at the endpoint for Vendors (SM207060) as that will give you some pointers but to keep it simple your are trying to update the Contact Details with the name/email. This is nested under the vendor so we must call it by name MainContact and then use [ ] to enclose the details.

I may have a type in here as not tested it.

{
    "VendorID": {"value": "V00001"},
    "VendorName": {"value": "SSCI Energy Sdn Bhd"},

“MainContact”:

[
 {

   "Name": { "value": "Robert"},
    "Email": {"value": "robert@sscienergy.com.my"}
  }

  ]

}


9001
Freshman I
  • Author
  • Freshman I
  • June 19, 2023

Hi @dcomerford ,

I’m getting the below error while include the Maincontact. 

 

 

{

    "message": "The request is invalid.",

    "modelState": {

        "": [

            "Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path 'MainContact', line 9, position 9."

        ]

    }

}

 

My payload below

{

    "VendorID": {

        "value": "V00001"

    },

    "VendorName": {

        "value": "SSCI Energy Sdn Bhd"

    },

    "MainContact": 

        [

            {

                "Name": {

                    "value": "Riayah"

                },

                "Email": {

                    "value": "riayaht@sscienergy.com.my"

                }

            }

        ]

    }

 

 


dcomerford
Captain II
Forum|alt.badge.img+15
  • Captain II
  • June 19, 2023

Apologies sorry I have the Sales Order in my head, i think the easiest way to do it is extend the existing end point and then use the Extend Entity to then add the two fields you are after (see below). You should then be able to post it it using your existing put just to your new endpoint.

 


Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

@9001,

Primary contact and account address are a part of the default endpoint. Below are the details,

  • PrimaryContact is mapped to the PrimaryContact entity of the Vendor entity
  • Account Address is mapped to the MainContact->Address of the Vendor entity

Below is the screenshot and marking of the entities and few contact fields for your reference,

So to expand these entities, you can try the following,

<<Acumatica URL>>/entity/Default/22.200.001/Vendor?$filter=VendorID eq 'AASERVICES'&$expand=PrimaryContact,MainContact/Address

 

To add/update values to their field you can try the following payload structure,

{
"VendorID": {
"value": "AASERVICES"
},
"MainContact": {
"Address": {
"AddressLine1": {
"value": "Line 1"
},
"AddressLine2": {
"value": "Line 2"
},
"City": {
"value": "Montreal"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "30042"
},
"State": {
"value": "GA"
}
}
},
"PrimaryContact": {
"FirstName": {
"value": "FirstName"
},
"LastName": {
"value": "LastName"
},
"Email": {
"value": "EMailTest@test.com"
},
"Phone1Type": {
"value": "Business 1"
},
"Phone1": {
"value": "789"
},
"Phone2Type": {
"value": "Business 1"
},
"Phone2": {
"value": "123"
}
}
}

Hope that helps.!

Good Luck, feel free to post if you have follow-up questions


9001
Freshman I
  • Author
  • Freshman I
  • June 20, 2023

@Vignesh Ponnusamy Thanks It works