I'm trying to implement a workflow in which I will be invoking multiple REST API calls to create a nested folder structure in SharePoint. To achieve this, I have used a GET API call to check whether the folder I'm attempting to create already exists in the path. However, using the Response and the Output variables did not yield the desired results in fetching the HTTP Status Code, as the workflow would not continue after the initial GET call.
Is this the correct approach to achieve the desired outcome, or is there an alternative way to implement this scenario?
Page 1 / 1
Does the Response_ variables has any values? Also check the getCustLetterUrl variables content have any escape characters(As it is a url).
Hi Buddhi,
I verified the URL with the Postman and it works fine. As for the _Response variable I’m not able to check the value since it seems like the flow would not continue after the API call. I modified the variable as $._Response which I believe is the correct format but it seems like the issue right now is that after the API call everything comes to a halt.
@Buddhi Gunasekara I was able to modify the Workflow without using the REST Response, now it will work perfectly if the HTTP response is successful but I want the Workflow to continue and move on to the next step, even if I get an error response for the API call, it seems like using an output variable didn’t help because it would not continue to the gateway in case of a failure response to make use of the output variable. Do you have any suggestions on this?
You can identify what alternative response codes you want to handle and select them in “Add/Modify Response Codes”. Then workflow execution will move forward for selected response codes in addition to standard “Ok” responses. Keep in mind that you get a values to _Response variable only when there is a deviation from standard ok responses. This behavior is important if you’re using “_Response” variable in a gateway. Make sure to check for existence of variable in the execution before using.
@Buddhi Gunasekara Thank you! This worked for me.
@Buddhi Gunasekara I am having a similar issue that I’m hoping you may be able to help me with. I have two situations at the moment:
Valid Request
“response” output key is populated with the JSON response.
“ResponseCode” response variable is empty/undefined.
Invalid Request
“response” output key is empty/undefined.
“ResponseCode” response variable is “400”.
My issue is that I’d like the workflow to continue when there is an error code provided in the response, but I’d also like to access the response values so that I can display the error message to the user. Additionally, I’d like to have the ResponseCode when it is a successful request too so I can include different paths based on response type. Basically, I would like to have both values in both situations, as you would normally have in any web response. Is this possible?
Thanks in advance,
Dylan
@dritter Only the scenarios you described are implemented atm. If there’s an error code, rest call doesn’t assign the error message to a variable and for http status codes < 300, status code is not recorded into a variable. Please do a request to IFS if you feel this is a feature you like to see in future releases.
I will submit a request. I suppose in the meantime I will have to write the web requests in JavaScript so I can store both the response body and the response code into variables. Thank you for the help!
I will submit a request. I suppose in the meantime I will have to write the web requests in JavaScript so I can store both the response body and the response code into variables. Thank you for the help!
I would like to know how you write the web requests in JavaScript? Would you mind sharing this if you get it to work? I have the same need. Thank you!
Also, if you made that request as an ‘Idea’ here in IFS Community, would you mind linking it in this thread so we can upvote it? Again, thank you!
Hi @Mike The FSM TechnoGeek
I thought I’d be able to use fetch() or the XMLHttpRequest() object, but since the workflows run on the Nashorn engine, it doesn’t seem possible. We would have to edit the server-side Java to create an HTTP connection method, but I don’t think we have access to that.
I created an idea here. Please give it an upvote or a comment if you think it’s a good idea!