IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this forum will no longer be available. More details available on our FAQ.
Topic
  • 2 replies
  • Latest Post - ‏2019-08-18T14:26:39Z by harishpandola
harishpandola
harishpandola
23 Posts

Pinned topic Calling BPM REST API from CV

‏2019-08-13T22:25:20Z |

Hi All,

 

I am trying to call BPM REST API using dojo/request/xhr.The code is as given below.

    var getSnapshotID = function(processId) {
    require(["dojo/request/xhr"], function(xhr) {
        var url = "rest/bpm/wle/v1/process/" + processId;
        xhr(url, {
            handleAs: "json",
            query: {
                parts: "all"
            },
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json'
            },
            method: "GET"
        }).then(function(data) {
            console.log('Data: ' + JSON.stringify(data));
                  var response =  JSON.stringify(data.snapshotID);
                  console.log('response: ' + response);
                  return response;
        }, function(err) {}, function(evt) {});
    })
}

 

In the console I observed that it is hitting the URL : https://hostname:portnumber/teamworks/rest/bpm/wle/v1/process/1261?parts=all 404

 

The issue is created by "teamworks" parameter which is not required for calling the BPM REST API.The correct URL it should hit is : 

https://hostname:portnumber/rest/bpm/wle/v1/process/1261?parts=all

 

How do i achieve this?

 

Thanks

  • AndrewPaier
    AndrewPaier
    1198 Posts
    ACCEPTED ANSWER

    Re: Calling BPM REST API from CV

    ‏2019-08-15T14:10:34Z  

    You need to change your url to start with a "/" character.  Without that character the request is made to "application root" which, in this context is /teamworks.  So for your URL simply put in -

     

    var url = "/rest/bpm/wle/v1/process/" + processId;

    Which should make a request at the server root instead of the application root.

     

    -Andrew Paier

  • AndrewPaier
    AndrewPaier
    1198 Posts

    Re: Calling BPM REST API from CV

    ‏2019-08-15T14:10:34Z  

    You need to change your url to start with a "/" character.  Without that character the request is made to "application root" which, in this context is /teamworks.  So for your URL simply put in -

     

    var url = "/rest/bpm/wle/v1/process/" + processId;

    Which should make a request at the server root instead of the application root.

     

    -Andrew Paier

  • harishpandola
    harishpandola
    23 Posts

    Re: Calling BPM REST API from CV

    ‏2019-08-18T14:26:39Z  

    You need to change your url to start with a "/" character.  Without that character the request is made to "application root" which, in this context is /teamworks.  So for your URL simply put in -

     

    var url = "/rest/bpm/wle/v1/process/" + processId;

    Which should make a request at the server root instead of the application root.

     

    -Andrew Paier

    @Andrew Thanks for the response.I think this is the reason,though I captured the context root separately using below code,in case someone needs it in future.

     

    var rest = this.context.contextRootMap.rest;

     

    Thanks