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...
Suggested Answer

API page stopped working when Posting to it

(0) ShareShare
ReportReport
Posted on by 21

I have a custom API page and all of the sudden I can't post to the URL in the sandbox. Using postman, I can do a get or patch to the URL but when I do a post I get the following error:

 

System.InvalidOperationException: An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.\r\n at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request)\r\n at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)\r\n at Microsoft.Dynamics.Nav.Runtime.NavHttpClient.<>c__DisplayClass48_0.<SendWithTelemetry>b__0(CancellationToken ct) in s:\\repo\\src\\Platform\\Server\\Prod.Ncl\\Runtime\\NavHttpClient.cs:line 332\r\n at Microsoft.Dynamics.Nav.Types.NavCancellationToken.RunActionWithCancellationToken[T](Func`2 func) in s:\\repo\\src\\Platform\\ClientServerShared\\Prod.Types\\Cancellation\\NavCancellationToken.cs:line 140\r\n at Microsoft.Dynamics.Nav.Runtime.NavHttpClient.SendWithTelemetry(HttpRequestMessage requestMessage, String endpoint) in s:\\repo\\src\\Platform\\Server\\Prod.Ncl\\Runtime\\NavHttpClient.cs:line 331\r\n at Microsoft.Dynamics.Nav.Runtime.NavHttpClient.<>c__DisplayClass47_0.<Send>b__1() in s:\\repo\\src\\Platform\\Server\\Prod.Ncl\\Runtime\\NavHttpClient.cs:line 315\r\n at Microsoft.Dynamics.Nav.Types.NavThread.<>c__DisplayClass44_0.<RunExternalAction>b__0() in s:\\repo\\src\\Platform\\ClientServerShared\\Prod.Types\\ThreadScheduling\\NavThread.cs:line 431\r\n at Microsoft.Dynamics.Nav.Types.NavThread.RunExternalAction[T](Func`1 action) in s:\\repo\\src\\Platform\\ClientServerShared\\Prod.Types\\ThreadScheduling\\NavThread.cs:line 470\r\n at Microsoft.Dynamics.Nav.Runtime.TrappableHttpOperationExecutor.<>c__DisplayClass0_0.<Execute>b__0() in s:\\repo\\src\\Platform\\Server\\Prod.Ncl\\Runtime\\TrappableHttpOperationExecutor.cs:line 31\r\n at Microsoft.Dynamics.Nav.Runtime.TrappableOperationExecutor.Execute(DataError errorLevel, Func`1 operation, Action`2 processNativeException) in s:\\repo\\src\\Platform\\Server\\Prod.Ncl\\Runtime\\TrappableOperationExecutor.cs:line 34 CorrelationId: a9e87557-3553-4c95-91e8-f6e902bfe747.

 

Any idea what would be causing this?

 

Thanks

I have the same question (0)
  • steveendow Profile Picture
    2,281 on at

    I don't have any ideas as to the cause, but do you happen to have telemetry enabled for the Sandbox?

    I'm curious if it's emitting any info to App Insights that might help.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at

    I really have certain answer either. But to me the error indicates that you are not hitting the correct URL or that your base url is not correct.

    You should probably have an extra look at that.

  • steveendow Profile Picture
    2,281 on at

    Hey Inge,

    What I find strange is the stack trace.  If I attempt to post against an incorrect URL, I believe a very simple message is returned.

    For example, if I replace the "companies" endpoint with "fakeobject", it's a pretty simple return error message.

    {

       "error": {

           "code": "BadRequest_NotFound",

           "message": "Resource not found for the segment 'fakeobject'."

       }

    }

    The presence of the stack trace makes me think that it's an internal error--an unhandled exception.

    Rick,

    Other than verifying the URL is correct, the only thing I can think of is to remove the PTE / extension for the custom API page, and then reinstall it, just to see if that makes any difference.

  • Rick Folkner Profile Picture
    21 on at

    Thanks all for the suggestions.  I finally figured out the issue, there was an event on the Sales Header that was trying to run some code that was calling another api, it was this call that was getting the bad url error not my call to the initial api.  A little hard to track down by the error message.  

  • Inge M. Bruvik Profile Picture
    1,111 Moderator on at

    Happy that you figured it out and updated us with the solution.

    And steveendow - then i guess we both had kind of right :)

    It was both an url that did not work and some internal stuff happening.

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,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans