0

So I'm having problem with how I pass my data.

This is my WCF rest method

  [WebInvoke(UriTemplate = "/GetCustomFieldValues",
            Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped)]
        Dictionary<string, Object> GetCustomFieldValues(string pwaUrl, string projectUid, List<string> customFieldNames);

On Swagger this is my declaration for it

/GetCustomFieldValues:
    post:
      parameters:
        - name: Param
          in: body
          description: The custom field value you want to get
          required: true
          schema:
            $ref: "#/definitions/GetCustomFieldValues"
      responses:
        200:
          description: Getting custom field value using name
      summary: GetCustomFieldValues
      description: GetCustomFieldValues
      operationId: GetCustomFieldValues 
definitions:
  GetCustomFieldValues:
    type: object
    properties: 
      pwaUrl:
        type: string
      projectUid:
        type: string 
      customFieldNames:
        type: array 
        items: 
          type: string

When I used my Advanced Rest Client or Powershell the method works, the only difference is how I assemble the body.

For Swagger I need to use a definition since I can't do multiple parameters on body.

I'm also putting this at the top of the swagger

schemes:
  - http
consumes: 
  - application/json
produces:
  - application/json

1 Answers1

0

Weird thing about WCF,

CORS needs to be both Global.asx and web.config, this works on mine CORS enabled but response for preflight has invalid HTTP status code 404 when POSTing JSON