Skip to main content
Solved

REST API - Vendor Profile Update Issue

  • Jun 18, 2023 8:34 AM UTC
  • 5 replies
  • 400 views
  • Translate All

Ram Kumar
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

View original

5 replies

dcomerford
Captain II
Forum|alt.badge.img+16
  • Captain II
  • Jun 18, 2023 8:29 PM UTC

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"}
  }

  ]

}

Translate

Ram Kumar
Freshman I
  • Author
  • Freshman I
  • Jun 19, 2023 2:57 PM UTC

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"

                }

            }

        ]

    }

 

 

Translate

dcomerford
Captain II
Forum|alt.badge.img+16
  • Captain II
  • Jun 19, 2023 3:39 PM UTC

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.

 

Translate

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

Translate

Ram Kumar
Freshman I
  • Author
  • Freshman I
  • Jun 20, 2023 10:16 AM UTC

@Vignesh Ponnusamy Thanks It works 

Translate