Question

Erikest on Tue, 17 May 2016 21:33:11


Ooof, internal server error prevented my last lengthy, well formatted post with clear example code and clever points made.  Good bye forever keystrokes, you won't benefit anyone now and that's too bad since as Hanselman would say, I only have so many keysleft.com... But I've blown them on less worthy causes before, so what's one more forum post, eh?

Okay, briefly and less elegantly:  In the logic app, I've manually added the body:

            "inputs": {
                "body":"@triggerBody()",

because it won't allow me to select the entire trigger body and pass it to the single parameter of my action, which was originally defined as

 public void Post(S_Contact contact)

that signature should, eventually, cause the JSON formatter to deserialize the body into an S_Contact object.

However, the swagger it creates expands the S_Contact into its constituent properties, FirstName and LastName and calls them modelbinding parameters.  In the logic app, this shows nothing, not even two boxes for FirstName and LastName.

So, I changed the action signature to:

public void Post([FromBody] S_Contact contact)

which changes the swagger to:

			"post" : {
				"tags" : ["Values"],
				"operationId" : "ApiValuesPost",
				"produces" : [],
				"parameters" : [{
						"name" : "contact",
						"in" : "body",
						"required" : false,
						"schema" : {
							"$ref" : "#/definitions/S_Contact"
						}
					}
				],
				"responses" : {
					"204" : {
						"description" : "No Content"
					}
				},
				"deprecated" : false
			}

which is closer because it recognizes the single parameter of my action.  However, in the logic app designer, it expands this out and has me selecting FirstName and LastName bindings individually (I realize because it is using the 'definitions' section of the swagger doc), which led me back to manually setting:

            "inputs": {
                "body":"@triggerBody()",

which works!  this successfully passes the entire body to my action which deserializes appropriately.

However, I feel that I'm either

  • doing something wrong (hopefully that's the case) or
  • encountering a bug or unimplemented feature. 

Thoughts?  Is this the intended workflow?  

I'd like to select my api action and have the designer walk through the logic of, "hmm the action has one parameter and this trigger here from the managed salesforce api is working with one object as well - I think I'll assign the single output to the single input by default"


Replies

Jeff Hollan [MSFT] on Wed, 18 May 2016 15:54:53


Thanks for taking the time to re-write the post - very helpful.  Yes we are aware of the gap right now in that swagger automatically "unwraps" the object so if you are passing in the entire object as above by default swagger will overwrite.  We have a feature in the backlog to allow exactly what you are doing without having to tweak the swagger - but for now the workaround is as you described - modify the swagger so it only expects a single parameter and the API itself will be able to deserialize the object as needed.