none
Parameter not initialized in custom api app RRS feed

  • Question

  • I have a very simple Logic app with two API apps, twitter and a customer api app(uses the default OOB valuecontroller and pretty much does nothing). code view of the action section below, where I tried to pass the text of a search tweet result to the post method on the valueController. When I attach to the custom api app remotely via debugger in VS, put a bp in Post method and manually start the logic app, the parameter "value" in Post method is null, shouldn't it be initialized with the result of the first tweet that contains the keyword I specified?

        "actions": {
            "twitterconnector": {
                "type": "ApiApp",
                "inputs": {
                    "apiVersion": "2015-01-14",
                    "host": {
                        "id": "/subscriptions/xxxxxx/resourcegroups/default-web-westus/providers/Microsoft.AppService/apiapps/twitterconnector",
                        "gateway": "https://default-web-westusxxxxxxx.azurewebsites.net"
                    },
                    "operation": "SearchTweets",
                    "parameters": {
                        "Query": "#helloworld",
                        "MaxResults": 20
                    },
                    "authentication": {
                        "type": "Raw",
                        "scheme": "Zumo",
                        "parameter": "@parameters('/subscriptions/xxxxxxx/resourcegroups/default-web-westus/providers/Microsoft.AppService/apiapps/twitterconnector/token')"
                    }
                },
                "repeat": null,
                "conditions": []
            },
            "helloworldapiapp": {
                "type": "ApiApp",
                "inputs": {
                    "apiVersion": "2015-01-14",
                    "host": {
                        "id": "/subscriptions/xxxxxxxx/resourcegroups/default-web-westus/providers/Microsoft.AppService/apiapps/helloworldapiapp",
                        "gateway": "https://default-web-westusxxxxx.azurewebsites.net"
                    },
                    "operation": "Values_Post",
                    "parameters": {
                        "value": "@first(body('twitterconnector')).TweetText"
                    },
                    "authentication": {
                        "type": "Raw",
                        "scheme": "Zumo",
                        "parameter": "@parameters('/subscriptions/xxxxxxx/resourcegroups/default-web-westus/providers/Microsoft.AppService/apiapps/helloworldapiapp/token')"
                    }
                },
                "repeat": null,
                "conditions": [
                    {
                        "dependsOn": "twitterconnector"
                    }
                ]
            }

    I looked at the input link of my logic app run(below), it looks like 'value' does get initialized from a tweet, but for some reason, in my debugger, the string parameter "value" is null.

    {
        "host": {
            "gateway": "https://default-web-xxxx.azurewebsites.net/",
            "id": "/subscriptions/xxxxx/resourcegroups/default-web-westus/providers/Microsoft.AppService/apiapps/helloworldapiapp"
        },
        "operation": "Values_Post",
        "parameters": {
            "value": "RT @parco_otsu: 京都のあとは、滋賀県の琵琶湖へ!  #ingress   #jwave   #helloworld   #hw813  http://t.co/jSFYYEPFsP  @mask303 @helloworld813 @DJ_TARO http:/…"
        },
        "apiVersion": "2015-01-14",
        "authentication": {
            "scheme": "Zumo",
            "type": "Raw"
        }
    }

    Friday, March 27, 2015 7:20 AM

All replies

  • Can you share your swagger definition of your app?  Or the WebAPI method signature?  It looks like the data is being sent correctly from the Logic App to the Gateway.

    Friday, March 27, 2015 11:22 AM
    Moderator
  • This is the default ValueController when one creates an Azure API App project.

        public class ValuesController : ApiController
        {
            // GET api/values
            public IEnumerable<string> Get()
            {
                return new string[] { "value1", "value2" };
            }

            // GET api/values/5
            public string GetById(int id)
            {
                return "value";
            }

            // POST api/values
            public void Post([FromBody]string value)
            {
            }

            // PUT api/values/5
            public void Put(int id, [FromBody]string value)
            {
            }

            // DELETE api/values/5
            public void Delete(int id)
            {
            }
        }

    {
      "swagger": "2.0",
      "info": {
        "version": "v1",
        "title": "HelloWorldAPIAPP"
      },
      "host": "microsoft-apiappdf57a2dcbba148279f3c357bf67e4c6b.azurewebsites.net",
      "schemes": [
        "https"
      ],
      "paths": {
        "/api/Values": {
          "get": {
            "tags": [
              "Values"
            ],
            "operationId": "Values_Get",
            "consumes": [],
            "produces": [
              "application/json",
              "text/json",
              "application/xml",
              "text/xml"
            ],
            "responses": {
              "200": {
                "description": "OK",
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            },
            "deprecated": false
          },
          "post": {
            "tags": [
              "Values"
            ],
            "operationId": "Values_Post",
            "consumes": [
              "application/json",
              "text/json",
              "application/xml",
              "text/xml",
              "application/x-www-form-urlencoded"
            ],
            "produces": [],
            "parameters": [
              {
                "name": "value",
                "in": "body",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            ],
            "responses": {
              "204": {
                "description": "No Content"
              }
            },
            "deprecated": false
          }
        },
        "/api/Values/{id}": {
          "get": {
            "tags": [
              "Values"
            ],
            "operationId": "Values_GetById",
            "consumes": [],
            "produces": [
              "application/json",
              "text/json",
              "application/xml",
              "text/xml"
            ],
            "parameters": [
              {
                "name": "id",
                "in": "path",
                "required": true,
                "type": "integer",
                "format": "int32"
              }
            ],
            "responses": {
              "200": {
                "description": "OK",
                "schema": {
                  "type": "string"
                }
              }
            },
            "deprecated": false
          },
          "put": {
            "tags": [
              "Values"
            ],
            "operationId": "Values_Put",
            "consumes": [
              "application/json",
              "text/json",
              "application/xml",
              "text/xml",
              "application/x-www-form-urlencoded"
            ],
            "produces": [],
            "parameters": [
              {
                "name": "id",
                "in": "path",
                "required": true,
                "type": "integer",
                "format": "int32"
              },
              {
                "name": "value",
                "in": "body",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            ],
            "responses": {
              "204": {
                "description": "No Content"
              }
            },
            "deprecated": false
          },
          "delete": {
            "tags": [
              "Values"
            ],
            "operationId": "Values_Delete",
            "consumes": [],
            "produces": [],
            "parameters": [
              {
                "name": "id",
                "in": "path",
                "required": true,
                "type": "integer",
                "format": "int32"
              }
            ],
            "responses": {
              "204": {
                "description": "No Content"
              }
            },
            "deprecated": false
          }
        }
      },
      "definitions": {}
    }

    Friday, March 27, 2015 5:42 PM
  • Hi Paul, did you get to the bottom of this one?

    http://twitter.com/joshtwist

    Tuesday, May 12, 2015 4:26 AM
  • Hi Paul,

    I think parameter binding in Web API went for a toss here. Would the following unblock you: Can you make the "string value" parameter in the post method a uri parameter ([FromUri]string value) instead of picking it from Body? If you really want it from Body - Can you consider having a Model class like "public void Post(ValueModel model)" where ValueModel just one field "string value"?

    Let me know if this resolves this issue.

    

    Tuesday, May 12, 2015 3:59 PM