0

I have a simple external service definition that can return a 202 or a 401.

I cannot figure out how to tell which response code is returned.

The endpoint is an azure HTTP endpoint on microsoft power automate.

It is receiving and consuming the POST properly.

It does not return anything on success so there are no body parameters to evaluate.

I've tried assigning the action output to a text variable and displaying on a screen, and have also tried displaying the output directly on a screen, and they are all empty / null.

I have confirmed via postman that i will receive a 202 when i POST to the endpoint.

Feels like I am missing something fundamental here (likely, in fact...) but not sure where to go now.

The endpoint definition is as follows

{
    "swagger": "2.0",
    "info": {
       "title": "MSFT Endpoint",
       "description": "Send id to msft power automate.",
       "version": "1.0.0"
    },
    "paths": {
       "/": {
          "post": {
             "summary": "sends the id.",
             "consumes": [
                "application/json"
             ],          
          "produces":[
            "application/json"
         ],
          "parameters": [
             {
                "in": "body",
                "name": "inputparms",
                "description": "id and process",
                "schema": {
                   "type": "object",
                   "properties" : {
                     "recordId" : {
                       "type": "string"
                     },
                     "processName": {
                       "type": "string"
                     }
                   }
                }
             }
          ],
          "responses": {
             "202": {
                "description": "Success!",
                "headers": {
                  "status" : {
                    "type" : "string"                    
                  }
                }
             },
             "401": {
               "description": "auth issue",
               "schema": {
                 "$ref": "#/definitions/Error"
               }
             },
              "default": {
                "description": "Unexpected error",
                "schema": {
                "$ref": "#/definitions/Error"
                }
              }         
             }
          }
       }
    }
    ,
    "definitions": {
    "Error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ]
    } 
    }
 }

Screenshot of the flow and the result below

overview:

flow overview

final output screen display text:

flow screen build

final output screen result:

flow screen result

EDIT : Adding some more things I have tried, and figured it out.

Tried manually mapping the output variables in the flow action

Tried automatically mapping the success and error action outputs in flow action and testing if they are null in a formula (both evaluated to false)

I ran in debug mode and can actually see the 202 in the output flow debug

I added a formula field to evaluate ISBLANK on 202 evaluates to FALSE, but ISBLANK on 401.code and defaultError.code evaluates to TRUE.

So that is the answer. If there is no response body to evaluate, use a formula to evaluate if the response is blank. flow screen - success

3
  • Send it is showing the status code base on your images??
    – Eric
    Jun 3, 2020 at 7:26
  • the '202 output' that is shown above is text entered by me on the flow screen display text element. the part after the colon is the auto generated output from the action, which would typically let you parse the response body, but as the body is empty, so there is nothing. i've tried formulas to evaluate if 202 or 401 output is null, but both evaluate to false. i've tried adding an empty object to the response in the external service, but that just threw unhandled fault "No content to map to Object due to end of input". seems like empty response assumes success?
    – gorav
    Jun 3, 2020 at 18:00
  • looks like i just needed to use isblank instead of isnull. blank vs null in flow often is a crapshoot for me, i need to sort that one out!
    – gorav
    Jun 3, 2020 at 18:42

1 Answer 1

0

If the API response has no parameters, then you can do the following:

Leave the option 'manually assign variables' unchecked on the action

Create a boolean formula field that evaluates if the action.response is blank for each response you want to evaluate. The example below is for the 202 response from the definition in the question.

flow formula field

This formula will evaluate to FALSE if this response code is returned. The other response codes will evaulate to TRUE. You can display the formula field in a flow screen display text element to validate the output.

flow screen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.