Error: PRS POST Operation

0
Hi everyone, I tried to create a POST operation of my PRS. I did everything according to this documentaton: https://docs.mendix.com/refguide/published-rest-services (except for error handling). I also downloaded the example project to get sure that everything is implemented correctly. Then I tried to execute the POST Operation of the Example fruit project that I found within the documentation. The problem now is, that I am not able to insert ANYTHING by clicking on “Try it out”. I am only able to execute the Operation, which returns an error (of course, I didn’t insert anything). What did I miss in the first place?   SOLUTION: It’s working now! I needed to change the Parameter type from “string” to “object”. Thanks to everyone who replied :)   Edit: Thanks everyone, I just added a Parameter, but still there is no insertion field: This is the Post MF: And this is the Parameter I’ve created:   Edit 2: this is my swagger.json:  {"swagger":"2.0","info":{"title":"fruit-v1","version":"1.0.0"},"host":"localhost:8080","basePath":"/rest/fruit-v1","schemes":["http"],"paths":{"/fruit":{" Edit get":{"tags":["fruit"],"summary":"Get a list of all fruits","description":"This operation returns a list of all **fruits**","responses":{"200":{"description":"successful operation","schema":{"type":"file"}}}},"post":{"tags":["fruit"],"summary":"Post a new fruit","description":"This operation creates a new **fruit**.\r\n\r\nThe expected body is:\r\n\r\n```\r\n{\r\n \"name\": \"banana\",\r\n \"color\": \"yellow\"\r\n}\r\n ```","parameters":[{"name":"FruitParameter","in":"body","type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"type":"file"}}}}},"/fruit/{name}":{"get":{"tags":["fruit"],"summary":"Get a specific fruit by its name","parameters":[{"name":"name","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"type":"file"}}}},"delete":{"tags":["fruit"],"summary":"Delete a specific fruit by its name","parameters":[{"name":"name","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"type":"file"}}}}}},"definitions":{"Fruit":{"xml":{"name":"Fruit"},"type":"object","properties":{"name":{"type":"string"},"color":{"type":"string"}}}},"tags":[{"name":"fruit","description":"# This is an overview of **fruit**"}]}    
asked
2 answers
3

Please try this

 

answered
1

If you can not post your body you probably need to create or change the parameter type in your rest service operation to ‘Body’. After deployment you will see a new field to put your json content.

answered