Solved

REST API - Vendor Profile Update Issue

  • 18 June 2023
  • 5 replies
  • 163 views

Userlevel 1

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 

icon

Best answer by Vignesh Ponnusamy 19 June 2023, 20:22

View original

5 replies

Userlevel 7
Badge +12

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

  ]

}

Userlevel 1

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"

                }

            }

        ]

    }

 

 

Userlevel 7
Badge +12

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.

 

Userlevel 7
Badge +4

@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

Userlevel 1

@Vignesh Ponnusamy Thanks It works 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved