0

Forgive my ignorance - a jr developer here. I'm trying to make a PUT call to a client API. In the documentation it shows the request headers have an object in them. I thought headers could only have a String value. How can I add an object to my HttpHeaders object?

Request Model from API Documentation

requestHeader {
  "headerA": "valueA",
  "headerB": {
    "headerB1": "valueB1",
    "headerB2": "valueB2"
  },
  "headerC": "valueC"
}

requestBody { 
  "object": { 
              "variable1": 12345, 
              "variable2": 54321 
  }, 
  "sameNums": false }

I'm using HttpHeaders from package org.springframework.http - the set() and add() methods take Strings as parameters. How can I add an object as a header value?

  • 1
    this might be helpful https://stackoverflow.com/questions/9779860/using-json-string-in-the-http-header – Pavel Jan 07 '23 at 05:07
  • From description of the task taken literally it seems you have to convert your object to its json representation and after insert it in the request header, the link suggested by @Pavel seems me very helpful. – dariosicily Jan 07 '23 at 10:18
  • @Pavel & dariosicily thank you! This was helpful and insightful – recklessbull47 Jan 23 '23 at 14:27

0 Answers0