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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Invalid URI: The hostname could not be parsed.

(0) ShareShare
ReportReport
Posted on by 55

Hi!

A few months ago we received a request to develop a way to open the print of an invoice through one form button (since it's a collaboration with a third-party company, the button would redirect the user from d365 to the other company website with the printed invoice). This development was supposedly correctly done, since everything was working properly on DEV branches and QA (TST) branches. The development was then merged into production environments.

The odd thing here is that the user complains about the error "Invalid URI: The hostname could not be parsed." when clicking the button, but none of my colleagues were able to recreate it. If we (developers) access LIVE environment and recreate his steps, we're redirected to the portal with the printed invoice, but the user isn't able to do that.

So far, we have:

  • Changed our permissions on LIVE environment to exactly match the user's permissions. Nothing seemed to change, as we were able to correctly open the invoice while he couldn't.
  • Verified, once again, on DEV / TST environments if everything was still working fine. It is.

Could it be an error in the code itself? If it was, it seems strange not to happen to anyone else besides 1 or 2 users (plus, everthing is working as intended in multiple environments, with multiple invoices, with multiple companies).

152646.png

I have the same question (0)
  • joaoasilva11 Profile Picture
    55 on at
    RE: Invalid URI: The hostname could not be parsed.

    Your idea helped massively. We updated the LIVE environment and managed to understand what was the actual URL "created" by the faulty user. Turns out it was a problem with permissions / priveleges, since we (as SYSADMIN) would create a proper URL given a certain InvoiceID and InvoiceURL, while the user created a URL with those fields in blank (the URL would therefore be something like ..."   "/xxx/"   " and not ....21933/xxx/thirdpartywebsiteURL.com. From our POV, the issue was in accessing the table that had that specific information, so we changed our code in order to store those said fields in a common and already used table.

    Waiting for the results as we speak, but the problem seems to be fixed.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Invalid URI: The hostname could not be parsed.

    Almost everything can cause issues, it's quite difficult to say since we don't know any details about your code that creates the URL. But you're closer to the solution once you can gather more information from prod system where the issue happens. 

  • joaoasilva11 Profile Picture
    55 on at
    RE: Invalid URI: The hostname could not be parsed.

    Those are some nice alternatives, haven't thought about that but I will start to work on it.

    Besides that, I also verified if everything was correctly approved on Azure (when the development was approved from TST to LIVE) and I found something odd (or at least I think so):

    • The original development changed the handler code (On Clicked), in order to open the third party website after clicking the button;
    • Since this was added to a form, both the handler and the form were modified and therefore changed in the LIVE environment;
    • When checking the updated form, I noticed the changes presented on the image below (and the updated object inside VS). Can these Link Type Join Source properties cause any issue for specific users only (again, due to corrupted records or anything remotely similar to that)?

    pastedimage1645800827456v2.pngpastedimage1645800797831v1.png

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Invalid URI: The hostname could not be parsed.

    Some hints to make it less invasive for daily users:

    - Show the infolog only for specific users (control with a new setup field on the user or something)

    - Show the infolog only if the error happens

    - Store the information to a table instead of showing infolog

  • joaoasilva11 Profile Picture
    55 on at
    RE: Invalid URI: The hostname could not be parsed.

    Seems dumb, I know. Will have to talk to my manager in order to see if that's a possibility or not, since it affects the day-to-day users (even if it's just a visual thing).

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Invalid URI: The hostname could not be parsed.

    So it only happens in Prod, but you didn't deploy the infolog logic to Prod to get more information? If it only happens in Prod, you must run it there to make progress. 

  • joaoasilva11 Profile Picture
    55 on at
    RE: Invalid URI: The hostname could not be parsed.

    I did, the URL is the same as the one I manually sent him (tested in DEV and TST, didn't approve this development to production, for obvious reasons). I added an Info() statement right after its creation // before the browser.navigate() and it's correct. I also asked the user to access my DEV environment and I debugged his steps, everything went according to plan and he managed to open the invoice image on the third party website without issues. The same thing happened in TST, for the same voucher / vendor account / intercompany. So, in summary, the issue ONLY happens in production (LIVE) environments but, as explained before, when I create an imaginary user with the exact same permissions as the faulty user, no errors occur.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Invalid URI: The hostname could not be parsed.

    Well, anything is possible. Did you already find a way to get the "url" that the user has (and which fails in procesing)? This would be really helpful and I think you should focus on this since it will definetely help you identify the problem.

    Any security privilege issues can easily be verified by letting the problematic user try it with System administrator role.

    Table caches are managed on AOS level, not user level. But if there would be some issue with the data, you would find it out when you see the "bad" URL that the system tries to process.

  • joaoasilva11 Profile Picture
    55 on at
    RE: Invalid URI: The hostname could not be parsed.

    Hi,

    I've done some modifications to the code in order to retrieve the URL before actually automatically opening it. The work flow works properly, as the URL is parsed correctly and, after clicking the said button, the tab opens the given URL correctly. After talking to the user, he told me that neither him or someone from his team are able to open the invoice through that specific button, it always retrieves the error Invalid URL.

    I recreated, once again, an example user with all of his permissions in the LIVE environment and everything seems to be working fine. Could it be some issue related to this (privileges / permissions)? For example, "on paper" he has X permissions but inside 365 he actually has Y permissions (which doesn't make sense, but still).

    I also thought about table caching. Since the invoice ID + Invoice URL are retrieved from one of our custom tables (and then merged together with custom code in order to form an actual feasible URL), could it have something to do with the values cached on the specific user table? I.e., for me everything is fine as I tested the issue AFTER it had happened, perhaps the user has some old records in cache that are corrupted (empty fields, corrupted data, etc.) and therefore can't open those specific invoices? Is it possible to table browse a table through a specific user in order to compare my records with theirs, for example?

  • joaoasilva11 Profile Picture
    55 on at
    RE: Invalid URI: The hostname could not be parsed.

    That's a valid point. I will make that adjustment and figure out what the URL is and if somehow it could be causing some issue. Will update soon!

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 785 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 626 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 621 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans