Search code examples
jsonwcffeathersjs

Feathers request WCF, single quotes vs double quotes in JSON


I am trying to call a WCF service using Feathers request framework (https://github.com/request/request) Feathers request framework is using single quotes around where as WCF is using double quotes.

{'name': 'Alice'} vs. {"name": "Alice"}

How can I get WCF to accept single quotes? or can I force Feathers request framework to use double quotes ?


Solution

  • The trick is to add the JSON object to the JSON property of the option passed in the request. JSON is then formatted correct and the WCF service can accept the request :)

    const option = {
      url:'http://..../NoteBasic.svc/json/SendMessageExecute',
      method: 'POST',
      json: {token: 'xxxxxxxx', message_id: 4}
    };
    request(option, function (err, httpResponse, body) {
      console.log(httpResponse);
    });