pachadotdev / analogsea

Digital Ocean R client
https://pacha.dev/analogsea/
Apache License 2.0
154 stars 24 forks source link

`domain_record_create()` fails with invalid body content #208

Open sjimellor-jr opened 3 years ago

sjimellor-jr commented 3 years ago

Issue:

domain_record_create() appears not to work at all as the body is being interpreted by DigitalOcean as JSON but sent as multipart. I have examples below, but don't know enough about chosing multipart/json to provide a real solution. Issue is present in version 1.0.0 (CRAN) and 1.0.1 (from GitHub).

Error message:

Error: invalid character '-' in numeric literal

Example: (requires DO managed domain)

analogsea::domain_record_create(
    domain = "example.com",
    type = "A",
    name = "testsubdomain",
    data = "1.1.1.1",
    ttl = 300
)

Alternative: (non-{analogsea}, this works)

httr::POST(
    "https://api.digitalocean.com/v2/domains/EXAMPLE.COM/records",
    body = list(type = "A", data = "1.1.1.1", name = "testsubdomain", ttl = 300),
    encode = "json",
    analogsea::do_oauth()
)

Not a solution:

This might have worked if {analogsea} didn't set encoding to multipart - I'm not familiar enough to know the reasoning behind this either way.

analogsea::domain_record_create(
    domain = "example.com",
    type = "A",
    name = "testsubdomain",
    data = "1.1.1.1",
    ttl = 300,
    encode = "json"
)

Error in do_POST(domain_record_url(domain$name), body = list(type = type,  : 
  formal argument "encode" matched by multiple actual arguments
Session Info ```r ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.0.2 (2020-06-22) os Ubuntu 18.04.5 LTS system x86_64, linux-gnu ui RStudio language (EN) collate C.UTF-8 ctype C.UTF-8 tz Europe/London date 2021-09-08 ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────── package * version date lib source analogsea 1.0.1 2021-09-08 [1] Github (sckott/analogsea@f468f0d) cachem 1.0.5 2021-05-15 [1] RSPM (R 4.0.4) callr 3.7.0 2021-04-20 [1] RSPM (R 4.0.4) cli 3.0.1 2021-07-17 [1] RSPM (R 4.0.5) crayon 1.4.1 2021-02-08 [1] RSPM (R 4.0.3) curl 4.3.2 2021-06-23 [1] RSPM (R 4.0.5) desc 1.3.0 2021-03-05 [1] RSPM (R 4.0.3) devtools 2.4.2 2021-06-07 [1] RSPM (R 4.0.5) ellipsis 0.3.2 2021-04-29 [1] RSPM (R 4.0.4) fastmap 1.1.0 2021-01-25 [1] RSPM (R 4.0.3) fs 1.5.0 2020-07-31 [1] RSPM (R 4.0.2) glue 1.4.2 2020-08-27 [1] RSPM (R 4.0.2) httr 1.4.2 2020-07-20 [1] RSPM (R 4.0.3) jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.0.2) lifecycle 1.0.0 2021-02-15 [1] RSPM (R 4.0.3) magrittr 2.0.1 2020-11-17 [1] RSPM (R 4.0.3) memoise 2.0.0 2021-01-26 [1] RSPM (R 4.0.3) pkgbuild 1.2.0 2020-12-15 [1] RSPM (R 4.0.3) pkgload 1.2.1 2021-04-06 [1] RSPM (R 4.0.4) prettyunits 1.1.1 2020-01-24 [1] RSPM (R 4.0.3) processx 3.5.2 2021-04-30 [1] RSPM (R 4.0.4) ps 1.6.0 2021-02-28 [1] RSPM (R 4.0.3) purrr 0.3.4 2020-04-17 [1] RSPM (R 4.0.3) R6 2.5.0 2020-10-28 [1] RSPM (R 4.0.2) remotes 2.4.0 2021-06-02 [1] RSPM (R 4.0.5) rlang 0.4.11 2021-04-30 [1] RSPM (R 4.0.4) rprojroot 2.0.2 2020-11-15 [1] RSPM (R 4.0.3) sessioninfo 1.1.1 2018-11-05 [1] RSPM (R 4.0.3) stringi 1.7.3 2021-07-16 [1] RSPM (R 4.0.5) stringr 1.4.0 2019-02-10 [1] RSPM (R 4.0.3) testthat 3.0.4 2021-07-01 [1] RSPM (R 4.0.5) usethis 2.0.1 2021-02-10 [1] RSPM (R 4.0.3) withr 2.4.2 2021-04-18 [1] RSPM (R 4.0.4) yaml 2.2.1 2020-02-01 [1] RSPM (R 4.0.0) [1] /home/seb/R/x86_64-pc-linux-gnu-library/4.0 [2] /opt/R/4.0.2/lib/R/library ```