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

Announcements

News and Announcements icon
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
    136 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,454 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,806 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,538

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans