When using R for posting json to a web api I got the error
Error in curl::curl_fetch_memory(url, handle = handle) :
Stream error in the HTTP/2 framing layer
But only after the first successful run. Strange. Something was hanging the handle in the background. Or that was my guess at least.
Anyway, if I set the version back to HTTP/1.1 it works fine.
Here is the gist of it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("httr") | |
httr::set_config(config(http_version = 2)) # set the HTTP version to 1.1 (none, 1.0, 1.1, 2) | |
sendMail <- function(e){ | |
body <- list(secret = 'sfsdf£$4500dfdd__$$', body=e["message"]) # create a list that will be serialized to JSON | |
result <- POST(url = "https://prod-10.westeurope.logic.azure.com/workflows/8934jadajada999" | |
, body = body , encode = "json", handle = NULL) | |
} | |
myProcess <- function(){ | |
stop("error") | |
} | |
tryCatch(myProcess(), error = sendMail) |
Hi great reading your bblog
LikeLike