Press "Enter" to skip to content

202 Status Code and the Asynchronous Pattern | Power Automate

On occasion, a support call is raised with Encodian or a community user reports an error with an action processing a document in some way, typically generating an error message such as:

InvalidTemplate. Unable to process template language expressions in action ‘Create_file’ inputs at line ‘1’ and column ‘2714’: ‘The template language function ‘base64ToBinary’ expects its parameter to be a string. The provided value is of type ‘Null’. Please see https://aka.ms/logicexpressions#base64ToBinary for usage details.’

An example error is illustrated below:

The key element of the error message is: “The provided value is of type ‘Null’.

This simply means that a file is not being passed to the ‘SharePoint Create File‘ action which is why it fails to create the file… but the Encodian action has succeeded so why is a file not being passed to the ‘SharePoint Create File‘ action?

Asynchronous Pattern in Microsoft Power Automate

Whilst the Encodian ‘Convert to PDF’ action has technically succeded it hasn’t returned a 200 status code but a 202 status code… this is detailed on the output which also shows that a file hasn’t been returned.

Technically nothing has actually failed, as a 202 status code is considered a successful status code, however, a 202 status code indicates that a request has been successfully accepted, not that is has completed! … but, rather than going into a detailed explanation of HTTP status codes and asynchronous processing, we’ll focus on fixing the issue which is super simple!

Let’s fix this issue!

1. Open the settings of the action which is returning the 202 status code.

2. Click to enable the ‘Asynchronous Pattern‘, click ‘Done

That’s it all fixed! If you’re interested there’s some extra technical detail below for reference:

NOTE: The Asynchronous Pattern is enabled by default, this only ever becomes an issue when it has been purposefully disabled.

A bit more technical detail…

A 202 response code means that the web server accepted the request but has not yet completed processing the job, the HTTP response provided would include an HTTP header called ‘Location’ the value of which contains a URL which the caller should subsquently call to obtain the final result.

Any connector which processes files in Power Automate should really adopt this approach (most do), as a synchronous call will timeout after 90 seconds which may not be enough time for long-running operations to complete, for example, OCR’ing a 100-page document could take 5 minutes or more

More details on this pattern can be found here: https://docs.microsoft.com/en-us/azure/architecture/patterns/async-request-reply

Finally…

We hope you’ve found this post useful, and as ever, please share any feedback or comments – all are welcome! If you still have a technical query please contact our support team via https://support.encodian.com

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *