Team,
I have a small query, Suppose I have created 1 web api say getcustomer()
DesktopModules/Leads/API/LeadsDisposition/getcustomer
Now I have 2 domain 1 is main domain say www.maindomain.com and other is subdomain say www.subdomain.maindomain.com
Now can we set api address like
www.subdomain.maindomain.com/DesktopModules/Leads/API/LeadsDisposition/getcustomer
instead of
www.maindomain.com/DesktopModules/Leads/API/LeadsDisposition/getcustomer
Inshort can we set base url as subdomain for web api?
Please suggest. Awaiting for your response.
Posted By Brian Dukes on 11/15/2022 6:02 AM The API that you've declared should be accessible from all portal aliases. Are you getting an error using the other domain?
As Brian mentioned, there's nothing you need to do for the other websites on your DNN instance to also use the same API endpoints.
The very nature of how the calls are made will always ensure that API calls from Site1 to the API are for and returned to the Site1 calling code.
So a call made from the maindomain.com to API endpoint will automatically know and use the same domain.
Then, if another site calls, such as subdomain.mainsite.com, it will have the same path, but on a different domain... The code is still the same.
So a call made from the subdomain.maindomain.com to API endpoint will automatically know and use the same subdomain.
There is nothing more you need to do. Most of the time, the main issues are not with the domain name, but the path that Web API has and what you expect it to be. :)
Thanks for your reply, Unfortunately I am getting below error while calling API using subdomain,
Error: getaddrinfo ENOTFOUND subdomain.maindomain.com
eventhough my actual subdomain is different but I am getting above error. Please suggest.
I would also suggest looking in your code for anything that might be specifically targeting and/or expecting a hard-coded domain name. If you have such code, that would be the first place I'd look to figure out why only one domain is having the issue.
Beyond that, I still sometimes find myself adding and using the following tool to diagnose issues with Web API in DNN. Though, there might be a better one these days. Not sure...
https://github.com/jbrinkman/dnnGlimpse
Oh, and regarding Brian's suggestion, you can use any client-side inspection tool to detect that, including the web developer tools in any contemporary web browser, and ones like Postman.
Issue is yet to resolve, I am sharing below 2 postman screenshot 1 is through root domain and other through subdomain. Through Subdomain I am still getting error. but same subdomain we are using for long time which is working fine. We are only facing issue when this subdomain used for Web API, I don't know is there any routing configuration issue or not, if it is not then what else. I don't know what are the things I am missing. Please guide.
1. Root Domain
2. Sub Domain
Regards,
Shyamal
It sounds like you might need to troubleshoot your route, because it can be tricky, depending on how you've registered your routes. I just created a blog post and video to help you.
https://dnncommunity.org/...eb-API-Routes-in-DNN
I have installed Glimpse and also eanabled it successfully but unfortunately after reload the page it does not show up that big G. So due to it is not visible unable to inspect the API routes . Please suggest if any other way I can check that.
These Forums are dedicated to the discussion of DNN Platform.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.