DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

404 with web api

Sort:
You are not authorized to post a reply.





Growing Member





    I am trying to create a DNN module by following Clint Patterson's tutorial from 2014. When I get to the Hello World Web API test I get a 404 error. Research shows that Web API changed in DNN 9.4 and I am wondering if this is the cause of my 404. If so, what is the proper way to do a Web Api call now?

    Later... got this to work, so no worries. Thanks.






    Veteran Member





      I guess I'm not surprised that the circa 2014 tutorial may not work with DNN 9.6.1

      Look for templates from Chris Hammond (christoc) and Will Strohl. I don't recall offhand if they have MVC examples.
      Joe Craig
      DNN MVP
      Patapsco Research Group





      Advanced Member





        Glad you got it to work later. Would you mind sharing your findings so that others can learn too?

        David Poindexter


        Creator:







        Veteran Member





          Usually, this is a typo in the router, the API path being called by the client-side code, or missing method decorations in the API methods.





          Growing Member





            I found that the URL I was using was actually pointing to the installed version of the module. I thought I was following instructions properly by creating a new subfolder in DesktopModules that would be unique, and then I put my development files in a subfolder there. So I have DesktopModules/ETI/ProfileUpdate folder with my VS files in it.  When I installed the install.zip into DNN, it placed the install in DesktopModules/ProfileUpdate.  So I actually had two versions then, the development one and the installed one.

            I got the HelloWorld URL to work by doing an install of the latest version of the project and all worked fine.

            Later I discovered that the JSON call did not resolve to the full URL when I specified "/DesktopModules/ProfileUpdate/API/ModuleFields/GetFields?moduleID=123" and it was lacking the protocol and domain.  I then updated it to:

            $.getJSON(
                    location.origin + "/dotnetnuke" + "/DesktopModules/ProfileUpdate/API/ModuleFields/GetFields?moduleID=123",
                   function (result) {
                       var parsedTaskJSONObject = jQuery.parseJSON(result);
                       console.log(parsedTaskJSONObject);             
                    });

            to get it to work, still knowing that I needed a proper solution if I was to deploy it.

            I am now thinking that there must be a better way, since I simply want to create a module that allows an admin to set a value on some particular element of a user's Profile whenever that module is on a certain page. User goes to that page; that value gets set in their Profile.

            Clint Patterson did an amazing job of putting that tutorial together, but as Joe says above, it is from 2014 and I find myself always wondering if things still work the same way as in the tutorial or if there is now a better way.

            I tried Chris Hammond's video on creating and packaging a module (#11), but didn't find the coding detail that Clint had. I've just discovered his #14 video, so I am going to try that.

             






            Veteran Member





              Thanks for the details.
              Joe Craig
              DNN MVP
              Patapsco Research Group
              You are not authorized to post a reply.

              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:

              1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
              2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
              3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
              4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
              5. No Flaming or Trolling.
              6. No Profanity, Racism, or Prejudice.
              7. Site Moderators have the final word on approving / removing a thread or post or comment.
              8. English language posting only, please.

              Would you like to help us?

              Awesome! Simply post in the forums using the link below and we'll get you started.

              Get Involved