Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Update render on demand API calls #71

Closed
wants to merge 3 commits into from
Closed

Conversation

nealrichardson
Copy link
Contributor

I chatted with @aronatkins and read through the source. To render, we don't need query params or body in the POST; params were removed in 2021. To send email, only query params are checked. So I simplified the recipe here.

@kmasiello I did not test that this code works--can you confirm using whatever example you were developing this with?

I'll separately update what connectapi does (which I think is where the confusion came from).

@kmasiello
Copy link
Collaborator

The python code works fine.

The R code does not.

image

If you want to test:

  • Environment: Colorado
  • content_guid: cdadc17a-418a-42d5-8212-cef7d639ee58
  • some valid variant keys: aCfL13z8, lsa46Ax3 (default)

@nealrichardson
Copy link
Contributor Author

For R, it looks like you dropped query and kept body. It should be the other way around.

@kmasiello
Copy link
Collaborator

No dice. It requires body

  client$POST(post_url, 
              query = list(email = recipients, rendering_id = rendering_id), 
              # body = list(email = recipients, rendering_id = rendering_id)
              )
}
Error:
! argument "body" is missing, with no default
Hide Traceback
    ▆
 1. └─client$POST(...)

@nealrichardson
Copy link
Contributor Author

Thanks. I'll poke at it some more.

@nealrichardson
Copy link
Contributor Author

I fixed the POST error in rstudio/connectapi#274. I've done some further simplification, depending on connectapi changes in rstudio/connectapi#277. There's more to pull on, but I don't have time right now. I will try to confirm the changes on Colorado.

# verify that variant key is either "default" or appears to be a valid entry.
if(variant_key != "default" && nchar(variant_key) != 8){
if (variant_key != "default" && nchar(variant_key) != 8) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: connectapi::get_variant() should cleanly handle the case where a variant key isn't found.

@kmasiello
Copy link
Collaborator

It's amazing! Installed connectapi from the dev branch and send_email works! 🎉

@toph-allen
Copy link
Collaborator

Code from this PR were incorporated into #125.

@toph-allen toph-allen closed this Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants