簡體   English   中英

httr庫中的POST方法,帶有R中的特定標頭

[英]POST Method in httr library with specific headers in R

我想接收JSON字符串作為來自REST API URL的響應。 它具有Header作為Content-Type=application/json 它應該具有json格式的主體,例如- {"string1":"string2","string3":"string4"}

這些是我在使用POSTMAN時輸入的詳細信息。 以上要求的正確語法是什么?

我正在嘗試以下語法,但始終會引發錯誤:

POST(url = login,add_headers('Content-Type'='application/json'),body = c("string1"="string2","string3"="string4"),encode = c("json"),verbose())

試試這個

POST(url = login,add_headers('Content-Type'='application/json'),body = list(string1="string2",string3="string4"),encode = "json",verbose())

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM