0

I'm working with an API where I need to post a couple of parameters. One of them is a colornumber. Below is my example. The problem is that once I use the command paste it adds a \ to the string. And therefore the command doesn't seem to work with the API. Is there a way to create a string that just sais {"argb" : -16777216 } in R.

paste('{"argb" : -16777216 }')
POST(url, authenticate(user, pw), body=list(58,'false','2000', '{"argb" : -16777216 }', 2000.0), encode= "json")
Ashoka
  • 139
  • 1
  • 6

1 Answers1

0

A couple of other posts on SO indicate that the \ is only there for clarification in the console output: https://stackoverflow.com/a/45363267/7547327

https://stackoverflow.com/a/4453083/7547327

And should work as if they're not there, but if it's not working, you can cat() the output to remove the backslashes:

``` r
paste('{"argb" : -16777216 }')
#> [1] "{\"argb\" : -16777216 }"

cat(paste('{"argb" : -16777216 }'))
#> {"argb" : -16777216 }

Created on 2022-03-14 by the reprex package (v2.0.1)

mrhellmann
  • 5,069
  • 11
  • 38