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 :
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)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Perhaps the site has a firewall blocking connections from the location where these 1-2 users are working?

    You can easily test this by asking those users to navigate directly to the link (without D365 at all).

  • joaoasilva11 Profile Picture
    55 on at

    I thought about that, but shouldn't that give an error on the "other website" end instead of a notification inside D365?

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    I can't really tell based on the details that you shared.

    Would you mind sharing the code?

  • joaoasilva11 Profile Picture
    55 on at

    I understand. Unfortunately I don't think I will be able to, even if it's nothing proprietary, I rather not reveal any component of it for company reasons. I will try your suggestion though, perhaps it could be something around the firewall issue.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Another suggestion is to try to print the URL to infolog in case the process fails.

    This way you can see what kind of string it's actually trying to navigate to.

    Who knows what string you're trying to parse into an URL.

    But it's really hard to answer your question "Could it be an error in the code itself" without seeing the code, as you can imagine.

  • joaoasilva11 Profile Picture
    55 on at

    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!

  • joaoasilva11 Profile Picture
    55 on at

    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?

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    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

    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.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    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. 

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans