[ad_1]
I am trying to use a prebuilt model API of Azure in R but facing some issues.
img_png <- png::readPNG("./images/2.png", native = TRUE, info = TRUE)
binary_img <- as.raw(img_png)
text_of_binary_img <- paste0(as.character(binary_img),collapse = "")
POST(URL,add_headers(.headers=c(`Ocp-Apim-Subscription-Key`= "subkey")), body=binary_img, content_type("image/png"))
returns invalid image error.
POST(URL,add_headers(.headers=c(`Ocp-Apim-Subscription-Key`= "subkey")), body=text_of_binary_img, content_type("image/png"))
throws the same error
POST(URL,add_headers(.headers=c(`Ocp-Apim-Subscription-Key`= "subkey")), body=upload_file("./images/2.png", type="image/png" ))
says content type is unknown and body is empty
API documentation is here.
Can anyone please help?
[ad_2]