2017-03-23 7 views
0

간단한 Swagger API 문서. 게시물을 수행하고 작업을 넣을 동안 매개 변수 내 컨트롤러에 전달하지 (가져 오기 및 삭제 작업을 잘 수행)POST/PUT 본문 매개 변수가 내 컨트롤러로 전달되지 않습니다.

Swaggerjson 파일 :.

"paths": {  
    "/api/AddEmployee": { 
     "post": { 
      "summary": "Add an Employee", 
      "description": "Adds a new Employee to the employees list.", 
      "consumes": [ 
       "application/x-www-form-urlencoded" 
      ], 
      "parameters": [ 
       { 
        "name": "body", 
        "in": "body", 
        "required": true, 
        "description": "An Employee to create.", 
        "schema": { 
         "$ref": "#/definitions/Employee" 
        } 
       } 
      ], 
      "responses": { 
       "200": { 
        "description": "Employee Added Sucessfully" 
       } 
      } 
     } 
    }, 
    "/api/UpdateEmployee": { 
     "post": { 
      "summary": "Update an Employee", 
      "description": "Updates an exist employee", 
      "consumes": [ 
       "application/x-www-form-urlencoded" 
      ], 
      "parameters": [ 
       { 
        "name": "body", 
        "in": "body", 
        "description": "An Employee to be updated.", 
        "schema": { 
         "$ref": "#/definitions/Employees" 
        } 

       } 
      ], 
      "responses": { 
       "200": { 
        "description": "Employee Added Sucessfully" 
       } 
      } 
     } 
    } 

}, 
"definitions": { 
    "Employees": { 
     "type": "object", 
     "properties": { 
      "EmpId": { 
       "type": "integer", 
       "format": "int32" 
      }, 
      "FirstName": { 
       "type": "string" 
      }, 
      "LastName": { 
       "type": "string" 
      }, 
      "age": { 
       "type": "integer" 
      } 
     } 
    }, 
    "Employee": { 
     "Type": "object", 
     "required": [ 
      "FirstName", 
      "LastName", 
      "age" 
     ], 
     "properties": { 
      "FirstName": { 
       "type": "string" 
      }, 
      "LastName": { 
       "type": "string" 
      }, 
      "age": { 
       "type": "integer" 
      } 
     } 
    } 

}

수있는이 문제에 어떤 하나의 가이드. 티아!

Controller Add and Update

Error Msg

+0

WebApi를 사용하고 계신지요? 그렇다면 요청을받을 것으로 예상되는 컨트롤러, 작업 및 경로 세부 정보를 게시 할 수 있습니까? 문제가있을 수 있습니다. –

+0

@ PhilCooper가 업데이트되었습니다. 지금 확인해 주시겠습니까? – k11k2

답변

0

큰 실수 :

"소비하는"[ "애플리케이션/x-www-form-urlencoded를" ]

변경하려면 다음

"소비": [ "application/json" ],