Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-15610

[fiware-stackoverflow] Error when I triying to do a POST request

    Details

      Description

      Created question in FIWARE Q/A platform on 25-03-2019 at 11:03
      Please, ANSWER this question AT https://stackoverflow.com/questions/55335716/error-when-i-triying-to-do-a-post-request

      Question:
      Error when I triying to do a POST request

      Description:
      I'm developing a script to do a post request to Orion Context Broker of Fiware. The problem is that a receive an error: "ContextLengthRequired", but I've Context-Length header in the request.

      This is de error when i tried node fiware.js

      {"error":"ContentLengthRequired","description":"Zero/No Content-Length in PUT/POST/PATCH request"}

      This is the code in the file "fiware.js":

      var request = require('request');

      var entity = {
      "id": "Room6",
      "type": "Room",
      "temperature":

      { "value": 23, "type": "Float" }

      ,
      "pressure":

      { "value": 700, "type": "Float" }

      };

      var jsonObject = JSON.stringify(entity);
      var aux = jsonObject.toString();
      aux = aux.length;

      var peticion = {
      url: "http://127.0.0.1:1026/v2/entities",
      method: "POST",
      headers:

      { "Content-Length": aux, "Content-Type": "application/json" }

      ,
      data: jsonObject
      };

      request(peticion, function(error, response, body)

      { console.log(error); console.log(body); }

      );

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        8d 23h 4m 1 Fernando Lopez 03/Apr/19 12:10 PM
        In Progress In Progress Answered Answered
        21s 1 Fernando Lopez 03/Apr/19 12:10 PM
        Answered Answered Closed Closed
        3s 1 Fernando Lopez 03/Apr/19 12:10 PM
        fla Fernando Lopez made changes -
        Fix Version/s 2021 [ 12600 ]
        fla Fernando Lopez made changes -
        Resolution Done [ 10000 ]
        Status Answered [ 10104 ] Closed [ 6 ]
        fla Fernando Lopez made changes -
        Status In Progress [ 3 ] Answered [ 10104 ]
        fla Fernando Lopez made changes -
        HD-Enabler Orion [ 10875 ]
        Description
        Created question in FIWARE Q/A platform on 25-03-2019 at 11:03
        {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/55335716/error-when-i-triying-to-do-a-post-request


        +Question:+
        Error when I triying to do a POST request

        +Description:+
        I'm developing a script to do a post request to Orion Context Broker of Fiware. The problem is that a receive an error: "ContextLengthRequired", but I've Context-Length header in the request.

        This is de error when i tried node fiware.js
        {"error":"ContentLengthRequired","description":"Zero/No Content-Length in PUT/POST/PATCH request"}

        This is the code in the file "fiware.js":

        var request = require('request');

        var entity = {
        "id": "Room6",
        "type": "Room",
        "temperature": {
            "value": 23,
            "type": "Float"
            },
        "pressure": {
            "value": 700,
            "type": "Float"
            }
        };



        var jsonObject = JSON.stringify(entity);
        var aux = jsonObject.toString();
        aux = aux.length;

        var peticion = {
          url: "http://127.0.0.1:1026/v2/entities",
          method: "POST",
          headers:{
                "Content-Length": aux,
                "Content-Type": "application/json"
          },
          data: jsonObject
        };

        request(peticion, function(error, response, body){
          console.log(error);
          console.log(body);
        });

        Created question in FIWARE Q/A platform on 25-03-2019 at 11:03
        {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/55335716/error-when-i-triying-to-do-a-post-request


        +Question:+
        Error when I triying to do a POST request

        +Description:+
        I'm developing a script to do a post request to Orion Context Broker of Fiware. The problem is that a receive an error: "ContextLengthRequired", but I've Context-Length header in the request.

        This is de error when i tried node fiware.js
        {"error":"ContentLengthRequired","description":"Zero/No Content-Length in PUT/POST/PATCH request"}

        This is the code in the file "fiware.js":

        var request = require('request');

        var entity = {
        "id": "Room6",
        "type": "Room",
        "temperature": {
            "value": 23,
            "type": "Float"
            },
        "pressure": {
            "value": 700,
            "type": "Float"
            }
        };



        var jsonObject = JSON.stringify(entity);
        var aux = jsonObject.toString();
        aux = aux.length;

        var peticion = {
          url: "http://127.0.0.1:1026/v2/entities",
          method: "POST",
          headers:{
                "Content-Length": aux,
                "Content-Type": "application/json"
          },
          data: jsonObject
        };

        request(peticion, function(error, response, body){
          console.log(error);
          console.log(body);
        });

        fla Fernando Lopez made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        fla Fernando Lopez made changes -
        Assignee Fernando Lopez [ fla ]
        backlogmanager Backlog Manager made changes -
        Field Original Value New Value
        Component/s FIWARE-TECH-HELP [ 10278 ]
        Hide
        backlogmanager Backlog Manager added a comment -

        2019-03-25 12:05|CREATED monitor | # answers= 0, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2019-03-25 12:05|CREATED monitor | # answers= 0, accepted answer= False
        backlogmanager Backlog Manager created issue -

          People

          • Assignee:
            fla Fernando Lopez
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: