9092

Postman PUT JSON Returns Null

Question:

I have this array that I am trying to use PUT to change the value of statuses. I am using Postman (A REST client -- <a href="http://www.getpostman.com/" rel="nofollow">http://www.getpostman.com/</a>). When I change over to the x-www-form-urlencoded tab and put the value of statuses to hello it updates accordingly. Below would be the result.

[ { __v: 0 _id: "XYXYXYXYXYXYXYXYXYXYXYXY" tagline: "Example tagline" title: "Example title" statuses: ["hello"] } ]

But when it gets more complex than a string in the array, I change the tab over to raw and try and do a JSON PUT request there by typing {"statuses":[{"userId": true}]}.

When doing a GET request, the following is the result.

[ { __v: 0 _id: "XYXYXYXYXYXYXYXYXYXYXYXY" tagline: "Example tagline" title: "Example title" statuses:null } ]

How come my JSON PUT request returns null? How can I change that?

Answer1:

We need to see your Node.js code to best answer you, but my guess is (I suppose you're using <a href="https://github.com/expressjs/body-parser" rel="nofollow">body-parser</a>) you need to set the extended option to true so that it's able to parse more complex bodies.

So that would be :

app.use(bodyParser.urlencoded({ extended: true}));

Recommend

  • Convert string to date and get difference
  • Populate Backbone Marionette Views with data from Mongoose using Express Route
  • Find based on calculated difference
  • Pushing item to Mongodb collection array
  • Android CalendarContract, deleting a recurring event causes all events to disappear on calendar?
  • FindAndModify, return array of Objects
  • Mongodb exception, “ MongoCursorException' with message '$ operator made object too large”
  • Install different versions of nuget packages inside one solution file with two projects
  • How do I recognize a line break with a switch case that evaluates a char in Java?
  • How to add System.Windows dll to Visual Studio 2010 express?
  • goJS dropdown remove items
  • Manually Timing out a C# Thread
  • Are there any side effects from calling SQLAlchemy flush() within code?
  • Jenkins Grails plugin does not list lastest versions of Grails
  • Outlines on links in IE9 remains when focus is changed
  • Kendo barchart category labels left and right based on value
  • Roxygen error “Skipping invalid path”
  • wxPython: displaying multiple widgets in same frame
  • MongoError: Incorrect arguments
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • Java: can you cast Class into a specific interface?
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Display issues when we change from one jquery mobile page to another in firefox
  • AES padding and writing the ciphertext to a disk file
  • Is possible to count alias result on mysql
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • To display the title for the current loaction in map in iphone
  • Calling of Constructors in a Java
  • AT Commands to Send SMS not working in Windows 8.1
  • php design question - will a Helper help here?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • AngularJs get employee from factory
  • trying to dynamically update Highchart column chart but series undefined
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Authorize attributes not working in MVC 4
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • How to push additional view controllers onto NavigationController but keep the TabBar?