0

I'm having some trouble getting a GET Action with body to work in BluePrism (using web api service).

It seems that when I try to include an Action that sends a GET with body when I reach that stage this error gets thrown:

Internal : Unexpected error Cannot send a content-body with this verb-type.

What I've tried:

  • Using a different verb-type / passing parameters in the query instead of the body, unfortunately i don't have control over the endpoint i'm trying to reach so this didnt work as it only accepts a GET containing data in the body
  • Using BluePrism HTTP Utility to send the call, this has the same problem as the Web API Service
  • Compiling the body via code instead of using a template

I haven't been able to find anyone that made it work in BluePrism and there doesn't seem to be much documentation on this issue in BluePrism so any help would be appreciated.

Thanks!

HiSpy
  • 17
  • 7
  • Take a look at this answer to a more general version of the same question: https://stackoverflow.com/a/3981584/3247151 Perhaps you can use a code stage to send the request and parse the return values. It's hard to know how to fix it without knowing the service call. – Mads T Jun 16 '22 at 11:19

2 Answers2

1

.NET's WebRequest class that Blue Prism uses under the hood to conduct these requests will not allow you to send a request body with any GET request. There is no (documented) way to overcome this limitation.

While other related answers on Stack Overflow correctly state that there exists no such prohibition on including request bodies with GET requests per RFC 9110§9.3.1, it is very unusual for a production-grade service to require that the request itself include anything in the request body. It's also possible that intermediaries like HTTP proxies may strip or otherwise mangle the request body in transit anyway.

There is no out-of-the-box way to force the .NET Framework (which Blue Prism uses) to send GET requests with a request body. If you're able, you can install WinHttpHandler and implement it as a drop-in replacement for HTTPRequest (this SO thread will help).

Because this type of solution requires the install of a new library, it's important to consider the caveats of doing so:

  • Blue Prism's support for external DLLs is unstable at best, and there's no guarantee it will even import correctly to begin with. Vendor support for this type of setup is, anecdotally, limited to nonexistent (and rightfully so, IMO).

  • If you're able to successfully implement the functionality described with WinHttpHandler, you'll need to install it on every Blue Prism developer's machine and runtime resource in all your environments (development/SIT/UAT/production). For some organizations, strict IT security posture makes this rather impractical or outright infeasible.

esqew
  • 42,425
  • 27
  • 92
  • 132
  • Thanks for the reply! I managed to get it working using reflection to set "ContentBodyNotAllowed" for GET to false (a bit of a hack!) – HiSpy Jun 19 '22 at 11:28
0

I managed to get it working using a code block containing C# code and using Reflection, here is a my GET method:

public string GetWithBodyAndAuth(string uri, string data, string token, out int statusCode)
{
    var request = (HttpWebRequest)WebRequest.Create(uri);
    
    
    request.Headers.Add("Authorization", "Basic " + token);
    request.ContentType = "application/json; charset=utf-8";
    request.Method = "GET";
    request.Accept = "application/json";

    var type = request.GetType();
    var currentMethod = type.GetProperty("CurrentMethod", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(request);

    var methodType = currentMethod.GetType();
    methodType.GetField("ContentBodyNotAllowed", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(currentMethod, false);

    using (var streamWriter = new StreamWriter(request.GetRequestStream()))
    {
        streamWriter.Write(data);
    }

    var response = (HttpWebResponse)request.GetResponse();
    StreamReader reader = new StreamReader(response.GetResponseStream());
    statusCode = ((int)response.StatusCode);
    return reader.ReadToEnd();
}

It's a bit of a hack and can't say if it'll be supported in the future, but for BluePrism 6.9 this allows you to send GET requests containing a body.

It has the advantage of not requiring any external DLLs, this is the import list:

Import List

HiSpy
  • 17
  • 7