New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POST requests from another server #1718
Comments
I'm assuming you mean you want to expose POST endpoints that will be available FROM this shiny server, TO other servers (that's what the title says, but the description is less clear on that, but I'll go with that assumption). You might like this video from RStudio Conf a few months ago, where @jcheng5 announced that this feature (called APIs) will be coming in the future as built into shiny. Start watching the video at minute 15:00. As of right now I don't think it's released yet, but you can probably experiment with the developmental version , I believe this feature is in one of the branches of this repo. I hope rstudio doesn't mind this info being publicized... |
No problem @daattali :) We are just waiting to release it until we have server-side support for authentication, which involves some other groups here at RStudio. |
Thanks a lot for the responses @daattali @jcheng5! The video is very helpful. A group of people using a certain software wants to send their data and feed my shiny without browsing and uploading the data. In design, it will be a button in this software which will open my app and run it. I wasn't able to respond their POST requests. So, I think we need wait for the new release... |
@jcheng5 I don't think our API branch actually covers this use case, right? What Shiny APIs allow for is to serve up artifacts from your app to another program through an http GET request. But it doesn't allow Shiny to receive http requests from the outside in any new way (right?) It seems that the "state of the art" there is still at the level of the second answer in the stackoverflow post linked above. You should take a quick read @jcheng5 (and @wch) -- I myself had no idea that was possible. Maybe we should expose that whole mechanism (handling GET and POST requests from other apps that flow into Shiny) a bit better? It seems that it would be a nice feature to have polished up by the time APIs are out. They're basically the mirror of one another... I'm bringing this up mostly because, if it's true, we really don't want @eralpdogu waiting for the API release, only to find that it doesn't help him at all... |
@daattali Just FYI, in addition to Joe's video, around that time, I also posted something on shiny-discuss that guides you through using the right branch from Github and the basic functionality of the API feature. If you're directing people to the video, this may be something good to pair it with, since there's a copy-pasteable example :) |
Good to know about that example code. My understanding is that he wants a program to send a POST request to a shiny app, and if I remember correctly then Joe did mention in his talk that both GET and POST are supported. Perhaps I'm misunderstanding his requirement though. |
Hi everyone, Thanks for the replies! I'm working with Eralp to understand what options are possible. Yes, the goal here is to integrate with a separate application that can launch a web browser and automatically POST data (the real payload is effectively an HTML <textarea> that contains a a CSV) to a configurable URL. Eralp has a Shiny app that currently prompts the user for a CSV file (via shinyUI() and fileInput()) and receives it via shinyServer() and observeEvent(). The hope was that we automatically launch the Shiny app and save the user from having to save the CSV and upload the file manually. From a quick review of the video you kindly linked, that sounds like it may work for this scenario, and that there wouldn't be a way to do it without those features. Thanks, |
@bborgesr That stackoverflow answer won't work for this case. And no, there's no specific reason why the API feature would be limited to GET, though I think generally GET calls will get more mileage out of a Shiny app's existing reactive expressions, so I'm emphasizing that use case. |
Hi everyone, I have a similar issue. As a workaround I've put a python script that accepts POST requests, put the files in a folder accessible to shiny app and generates a dataset key, which then can be passed via GET to a shiny app.
|
Hi everyone, For instance (this is a voluntarily dumb example): say I have a HTML form asking for a name, and I would like for it to redirect to my shinyapp when the action button is clicked, and for the shinyapp to "read" the name and display it. But even though this is very easy with the GET method (by accessing session$clientData$url_search), it seems that through POST I cannot even access the app, as if it voluntarily prevents POST requests to launch. Is there, by any chance, new info on the API feature release? I am having a hard time finding info on that. I am especially interested on what @jcheng5 mentions at the end of the video, on slide 24 (Recap): "URL parameters or JSON request bodies become input values". Thank you! |
No one? Just a small indication on the basic function(s) to call? |
@unplusun Could you convert the json to a set of query parameters which you pass via iframe url parameters? I don't think you'd be able to make it responsive (assume query strings parsed on first render?), but should be fine for simple cases where you just want to feed some initial data in. Here's the shiny doc reference for |
@chrismclarke Thank you for your answer! I have seen on the api branch, developped by @jcheng5, the existence of the parseJSONBody function, which seems to cover what I am looking for (I might be wrong) :
It seems to be requiring the use of the apiHandler function, defined also on the api branch. |
It got bumped in 2017 by the async features, which should be shipping soon. It also felt like lower priority because 1) plumber gaining popularity and 2) not very many people had expressed interest in the API stuff after my talk last year. But I received feedback from several people during rstudio::conf 2018 that they were waiting for it. So we'll try to get it back on the board after the async release, and I'll keep the use cases in this thread in mind. |
Adding a vote for this feature (session$api$data) from ticket # 33095. Thanks! |
Hi! Do we have any update on this? Is there a recommended way of accepting POST requests in a shiny server? |
Is there a way of getting data and reading it in Shiny using POST request? My data will flow from another software and I need to import it to analyze. Already tried the solution here https://stackoverflow.com/questions/25297489/accept-http-request-in-r-shiny-application but I need a more solid one.
The text was updated successfully, but these errors were encountered: