cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": "Resource not found"

Hi,

 

I’m using the same principle as described in Create a custom API using Azure Resource Manager in Microsoft Flow to Start/Stop an Azure Resource Manager Virtual Machine via Microsoft Flow.

 

When I register the swagger file as a custom API and create a new flow to use the Start/PowerOff actions,

The VM gets started/stopped properly like expected, but I get also a HTTP 404 error:

 

    "statusCode": 404, "message": "Resource not found"

 

The questions is how can I get more details about what is going wrong here? Or what is the reason behind this HTTP 404 ?

 

Screen capture: shows the 404 error code in the body of the output

Error 404 - Resource not foundError 404 - Resource not found

 

Screen capture: shows that i.e. the PowerOff operation is available on the designer

 

Flow element.jpg

 

Swagger file content - Only a part of swagger file is documented here to maintain the readability:

 

	  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/start": {
      "post": {
			"description": "Starts a given Virtual Machine",
			"summary": "Starts a given Virtual Machine",
			"operationId": "StartRmVM",
			"x-ms-visibility": "important",		
			"parameters": [
				{
				  "name": "api-version",
				  "x-ms-summary": "API version",
				  "in": "query",
				  "description": "API version",
				  "required": true,
				  "type": "string",
				  "default": "2016-03-30"
				},
				{
				  "name": "subscriptionId",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "resourceGroupName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "virtualMachineName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				}			
			],
			"responses": {
			  "200": {
				"description": "OK"
			  },
			  "400": {
				"description": "Bad Request"
			  },
			  "500": {
				"description": "Internal Server Error"
			  },
			  "default": {
				"description": "Operation Failed."
			  }
			}	
		 }
	  }
10 REPLIES 10
Highlighted
Microsoft
Microsoft

@MehrdadG Sorry you are seeing issues with this.

 

404 means Flow cannot reach the endpoint you specified. Have you made any changes to the Custom API template prior to uploading it on the Flow web site?

 

Also, can you please share te Flow name/ID? This can be done by editing your Flow on the Flow page and pasting the URL here on this thread.

 

Thanks!

Jade

Highlighted

Hi Jaden,

This is the full version of the swagger file I'm using to try it out,

 

Error detail:

OUTPUTS
Headers
{
  "Date": "Wed, 04 Jan 2017 07:15:58 GMT",
  "Server": "Microsoft-HTTPAPI/2.0",
  "Content-Length": "54",
  "Content-Type": "application/json"
}
Body
{
  "statusCode": 404,
  "message": "Resource not found"
}

 

Swagger file I'm using:

{
  "swagger": "2.0",
  "info": {
    "version": "1.0",
    "title": "ARM Sample",
    "description": "Access Azure Resources using this API to turn on/off a ARM Virtual Machine", 
    "contact": {
    "name": "sample",
    "email": "sample@non-existing.com"
    }
  },
  "host": "management.azure.com",
  "basePath": "/",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "AAD": {
      "type": "oauth2",
      "flow": "implicit",
      "authorizationUrl": "https://login.windows.net/common/oauth2/authorize",
      "scopes": {}
    }
  },
  "paths": {
	  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/start": {
      "post": {
			"description": "Starts a given Virtual Machine",
			"summary": "Starts a given Virtual Machine",
			"operationId": "StartRmVM",
			"x-ms-visibility": "important",		
			"parameters": [
				{
				  "name": "api-version",
				  "x-ms-summary": "API version",
				  "in": "query",
				  "description": "API version",
				  "required": true,
				  "type": "string",
				  "default": "2016-03-30"
				},
				{
				  "name": "subscriptionId",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "resourceGroupName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "virtualMachineName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				}			
			],
			"responses": {
			  "200": {
				"description": "OK"
			  },
			  "400": {
				"description": "Bad Request"
			  },
			  "500": {
				"description": "Internal Server Error"
			  },
			  "default": {
				"description": "Operation Failed."
			  }
			}	
		 }
	  },
	  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/powerOff": {
      "post": {
			"description": "PowerOff a given Virtual Machine",
			"summary": "PowerOff a given Virtual Machine",
			"operationId": "PowerOffRmVM",
			"x-ms-visibility": "important",		
			"parameters": [
				{
				  "name": "api-version",
				  "x-ms-summary": "API version",
				  "in": "query",
				  "description": "API version",
				  "required": true,
				  "type": "string",
				  "default": "2016-03-30"
				},
				{
				  "name": "subscriptionId",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "resourceGroupName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "virtualMachineName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				}			
			],
			"responses": {
			  "200": {
				"description": "OK"
			  },
			  "400": {
				"description": "Bad Request"
			  },
			  "500": {
				"description": "Internal Server Error"
			  },
			  "default": {
				"description": "Operation Failed."
			  }
			}	
		 }
	  }  
  }
}
Highlighted

Hi MehrdadG,

 

Thanks for the full version of the Swagger file. Could you also please provide your Flow Name and your Flow ID for a further investigation?

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

 

From the looks of it this probably means the params specified (e.g. resourceGroupName, subscriptionId, etc.) are leading to an invalid URL thus the 404 error.

 

The only way we can confirm this issue for you is if we have some identifiers for the Flow (e.g. Flow ID) itself so we can investigate on our end.

 

Thank you,

Jade

Highlighted

Hi,

 

Sorry about the long delay in between.

 

Here is the Url to the flow editor:

 

https://flow.microsoft.com/manage/environments/201481f5-c2da-4d1a-8f87-4c5ca33bca80/flows/aa698f76-8...

 

Hope this helps for further follow-up as the issue is still the same.

 

Please let me know if you need any additional details

..Thanks!

 

Kind regards,

MehrdadG

Highlighted

Any update on this subject?

 

Was the provided information sufficient? Is there anything more visible from backend logging why the HTTP 404 is occuring?

 

Kind regards,

MehrdadG

Highlighted

Hi @MehrdadG seems like the error is coming from the ARM APIs themselves. What you can do though is, inspect the request being made through the Flow using the "Test" Tab on the Custom API expereince.

 

More information on how to test your custom API is in this blog post : https://ms.flow.microsoft.com/en-us/blog/new-updates-custom-api/

 

Please let me know if this works for you, if not - I can try to debug this on our side.

 

Thanks,

Sunay

 

Highlighted

@MehrdadG Also in the swagger of your Custom API try specifying apiVersion as "2016-04-30-preview", according to the docs that's the latest version: https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-start 

Highlighted

Hi MehrdadG,

 

Can you check your link, it seems there is an error that indicates unavailability. It would be a great help if you could fix this.

 

ref - https://flow.microsoft.com/manage/environments/201481f5-c2da-4d1a-8f87-4c5ca33bca80/flows/aa698f76-8...

 

 

THanks

Asif

Highlighted

Hi folks,

 

I too am having this issue. What's weird is that I can see the calls to ARM actually succeed in the Azure activity logs. I also built a custom connector and added actions for start/stopping resources. These calls return a 202 in the Flow Connector Test tab, but a 404 when actually called by a flow (though again, the action actually succeeds and the resource starts / stops in Azure as requested).

 

I also tried adding handling for 404 and 202 response codes, and they do not seem to fire.

 

Edit: I am also using 2016-04-30-preview as my API version.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (7,893)