0

I am trying to pass header "X-Name" from postman then access it from API which is build using Plumber R.

However, I am not able to access it. using following code,

req$HTTP_X-NAME, then i am getting following error.

Error in (function (id, time_frame, req, res) : object 'name' not found\n"

If I use following code, I get NULL values,

req$HTTP_X_NAME  

or

req[["HTTP_X-NAME"]

or

req[["HTTP_X-Name"]

Following is my code:

#* @get /
healthCheck <- function(){
  print("It's Running")
}

#* @param id:int Random Number
#* @post /test/values
#* @get /test/values
test <- function(id, req, res){
  print(req[["HTTP_X-Name"]])
  return(req[["HTTP_X-Name"]])
}
Kush Patel
  • 3,685
  • 5
  • 42
  • 65
  • What about `req[["HTTP_X-NAME"]]`? It would be easier to help if you provided a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Aug 04 '17 at 16:50
  • @MrFlick That and the column name between back ticks. (If I post it here the SO editor will think that I'm posting code.) – Rui Barradas Aug 04 '17 at 16:53

0 Answers0