web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Patch Customer Name Using API

(0) ShareShare
ReportReport
Posted on by 185

Hello,

Am trying to Update the customer using API.

https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/api/dynamics_customer_update

It is working fine when am using Customer Table ID field is in url

https://{businesscentralPrefix}/api/v1.0/companies({id})/customers({id})

I want to Update Customer based on number field.

Like

https://{businesscentralPrefix}/api/v1.0/companies({id})/customers({number})

MyURL for patch:

api.businesscentral.dynamics.com/.../customers?$filters=number eq '6044913'

MyRequest

{
"displayName": "Adatum RAJu Corporation"

}

MyResponse:

{
"error": {
"code": "BadRequest_MethodNotAllowed",
"message": "'PATCH' requests for 'customers' of EdmType 'Collection' are not allowed within Dynamics 365 Business Central OData web services. CorrelationId: d8da1ad1-4d60-4379-8ff9-77fe9ac8e32b."
}
}

Same error for Delete operation.

How can we update customer record using number instead of ID.

Thank you.

  • Nilesh Gajjar India Profile Picture
    22 on at
  • Terrance Morgan Profile Picture
    515 on at

    The following example uses Java and HttpClient to update a record using REST API. Note that there is no PatchMethod in HttpClient, so PostMethod is overridden to return “PATCH” as its method name. This example assumes the resource URL has been passed in and contains the object name and record ID.

    public static void patch(String url, String sid) throws IOException {

    PostMethod m = new PostMethod(url) {

    @Override public String getName() { return "PATCH"; }

    };

    m.setRequestHeader("Authorization", "OAuth " + sid);

    Map<String, Object> accUpdate = new HashMap<String, Object>();

    accUpdate.put("Name", "Patch test");

    ObjectMapper mapper = new ObjectMapper();

    m.setRequestEntity(new StringRequestEntity(mapper.writeValueAsString(accUpdate), "application/json", "UTF-8"));

    HttpClient c = new HttpClient();

    int sc = c.executeMethod(m);

    System.out.println("PATCH call returned a status code of " + sc);

    if (sc > 299) {

    // deserialize the returned error message

    List<ApiError> errors = mapper.readValue(m.getResponseBodyAsStream(), new TypeReference<List<ApiError>>() {} );

    for (ApiError e : errors)

    System.out.println(e.errorCode + " " + e.message);

    }

    }

    private static class ApiError {

    public String errorCode;

    public String message;

    public String [] fields;

    }

    --
    Terrance
    MS Dynamics 365 Admin | Apps4Rent

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 545 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 354 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 228 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans