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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Character # (hash #) in URL after api/ causes unexpected Authentication_InvalidCredentials error

(0) ShareShare
ReportReport
Posted on by 9

Steps to reproduce

  1. Make a GET request to
    api.businesscentral.dynamics.com/.../companies
    (works)
  2. Add a url-encoded # anywhere after "api/"
    api.businesscentral.dynamics.com/.../c#ompanies
    fails with error code 'Authentication_InvalidCredentials'. Message 'The server has rejected the client credentials. CorrelationId: ...'
    (it worked before, so it is not due to invalid credentials)

Using a raw hash (not URL-encoded), results in an error: BadRequest_NotFound "Bad Request - Error in query syntax."

The response is the same for both custom APIs and the v2.0 API.


Why do I need a hash in the url?

We are trying to update the 'Manufacturer Code' field of an item. That field is not in the v2.0 Microsoft API, so we use a custom API, where an item is identified by the 'No' field. To update the manufacturer code of an item, I use OData and call:
PATCH api.businesscentral.dynamics.com/.../Items(No='...')

Many of our items contain # in their item number (No). 

Any help or alternative solution is welcome.

I have the same question (0)
  • Suggested answer
    Hasnain Ali Profile Picture
    134 on at

    Hi,

    Have you tried Encoding your URL?

    You can use this if it helps:

    var

           TypeHelper: Codeunit "Type Helper";

    begin

          URLpath := TypeHelper.UrlEncode(URLpath);

    end;

  • Radio Fred Profile Picture
    9 on at

    Thank you for your suggestion Hasnain Ali.

    Unfortunately I get the Authentication_InvalidCredentials error after URL-encoding the hash with %23

  • Verified answer
    Radio Fred Profile Picture
    9 on at
    We found a solution: Using OData batch requests does not result in the error described, and the field is updated correctly.
    Using OData transactional $batch requests - Business Central | Microsoft Learn

    The bug is still there, and batching is an extra step. So this is a workaround.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,468

#2
YUN ZHU Profile Picture

YUN ZHU 923 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans