Calling APIs from Excel VBA
Now, we are going to go over the code that will allow us to use a curl
request to obtain the image from the API that was generated from the plumber_api.R
file. In order to do this, you will have to run the code from the previous section: root |> pr_run()
; this is the portion that will open up the swagger dialogue and give you the URL that is running from plumber
. For me, at the time of this writing, it is as follows: http://127.0.0.1:6855
.
In this section, we are going to specifically execute the GET
request via a curl
command in VBA. Here is the code that will run, and the explanation will follow:
Sub MakeCurlRequestAndInsertImage() ' Define the curl command Dim curlCommand As String curlCommand = "curl -X GET ""http://127.0.0.1:6855/plot?.mean=0"" -H ""accept: image/png""...