xhrPost seems to be modifying the URL resulting in either 404 or 405?

88 views Asked by At

xhrPost seems to be modifying the URL resulting in either 404 or 405. This is from a custom widget and attempting to go to a REST service on a WebSphere Liberty server.

The rest service responds correctly when using RESTClient and building the request manually.

I am using var jsonData = JSON.stringify(domForm.toObject("TaskTemplate")); so I can verify the data is correct and sending the data as that string: data: jsonData,

the URL is hardcoded in the form and no substitution is currently being used:

 <form  id="TaskTemplate" name="TaskTemplate" 
 data-dojo-attach-point="taskTemplateNode" 
 method="POST" 
 action="http://localhost:9080/test2/rm/tasks/64/update">

I also have a GET with a URL of "http://localhost:9080/test2/rm/tasks/64/" that is working fine. Seems to be associated with PUT or POST...

When I do the xhrPost, I am getting the following error: "NetworkError: 404 Not Found - http://localhost:9080/test2/undefined"

since "undefined" is seen, it is like xhrPost is doing some substitution in the hardcode URL... I am using 1.9.2-20140219-IBM version of dojo which comes with Rational Application Developer. I have tried both xhrPost and xhrPut with the same results.

Here is the method that is invoked when the button is pushed:

 applySubmit: function() { 
         console.log("inside applySubmit");
         var jsonData = JSON.stringify(domForm.toObject("TaskTemplate"));
         console.log(jsonData);
         var xhrArgs = {
          // url: "http://localhost:9080/test2/rm/tasks/64/update",
          data: jsonData, 
          preventCache: true,
          timeout: 10000,
          handleAs: "text",
          contentType: "application/json",
          load: function(data) {
              console.debug("applySubmit success:" + data);
          },
          error: function(data) {
              console.debug("applySubmit error:");
          }
      };
 console.log("doing dojo.xhrPxxx(xhrArgs);");
 var deferred = dojo.xhrPost(xhrArgs);  // any need to save local var and exit?
 }

In the server logs, I am seeing [WARNING ] SRVE0190E: File not found: /undefined and that is coming from the webcontainer (makes sense given the error msg above) So, this means it is not related to my rest service, never gets to it.

This is really starting to delay our project, so any ideas about why this might be occurring would be greatly appreciated!

0

There are 0 answers