0

I know the following question might be quite obvious to others, and be defined as a total newbie question and I appology for that on behalf, but the fact is I have never worked with cURL or webhooks, and I have been unable to find a way to use this in the technologies I use for the development (Classic ASP, jQuery, Bootstrap, IIS).

The issue is that I have to use PDFmonkey (since it can use Bootstrap HTML code)to generate a PDF from a JSON post from my site, but the only 2 ways that PDFMonkey provide me to do this is using RUBY or cURL and I do not know where to start so I need some help.

My questions are:

  • How can I initiate the document generation in jQuery/Classic ASP with something similar to this:
curl 'https://api.pdfmonkey.io/api/v1/documents' \
  -H 'Authorization: Bearer [API KEY]' \
  -H 'Content-Type: application/json' \
  -d '{
        "document": {
          "document_template_id": "[TEMPLATE ID]",
          "payload": "{ \"name\": \"Jane Doe\" }",
          "status": "pending"
        }
      }'
  • .. then call for a status like this in cURL from jQuery/Classic ASP
curl 'https://api.pdfmonkey.io/api/v1/documents/d2f2de44-9de7-4dd8-90f4-bee5e99c9984' \
  -H 'Authorization: Bearer [API KEY]'
  • .. and finally receive the generated document information so I can display/save it in my site with something similar to:
curl https://your.website.com/replace-with-your-webhook \
  -H 'Content-Type: application/json' \
  -D- \
  -d '{
    "document": {
      "id": "11111111-2222-3333-4444-555555555555",
      "status": "success",
      "app_id": "22222222-3333-4444-5555-666666666666",
      "document_template_id": "33333333-4444-5555-6666-777777777777",
      "payload": "{\"name\":\"Jane Doe\"}",
      "checksum": "1234567890abcdefghijklmnopqrstuv",
      "download_url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
      "preview_url": null,
      "meta": null,
      "created_at": "2018-12-04T20:28:35.072+01:00",
      "updated_at": "2018-12-04T20:28:38.899+01:00"
    }
  }'

I do not know where to start, and have been looking for boot jQuery and Classic ASP solution both here on StackOverflow and google generally, but have not found a solution for the technologies I use, and on a Windows IIS platform, but my initial thoughts would be that this can be achieved in jQuery somehow and this would be the best solution over using Classic ASP.

Stig Kølbæk
  • 432
  • 2
  • 18
  • Partially @user692942 .. I can see that the post part of my issue can be handled with ASP using this method, which is great, but then I am left with the status request and finally the document request, and as I see it I have to use jQuery for that part since I have to dynamically listen for that response, or am I missing something? .. and how would I then use cURL in jQuery? – Stig Kølbæk Jun 10 '21 at 13:01
  • Ahh .. I have just found this post https://stackoverflow.com/questions/20155531/converting-curl-cmd-to-jquery-ajax[link] .. I think this combined with your suggestion @user692942, and some logic might solve my issue .. I will give it a go and see if I can get it to work and get back :-) – Stig Kølbæk Jun 10 '21 at 13:09
  • I don’t understand why you need jQuery involved at all as that will expose your API calls to the client-side? This question is way too board for [so] though, it supposed to be a specific problem not a series of problems. – user692942 Jun 10 '21 at 13:51
  • You might be right, I am might not be thinking strait here at the moment since cURL and weebhooks are totally new, maybe I should try your suggestion ad incorporate som logic in that by looping and asp_Wait to get the callback from PDFMonkey .. I will have a look at that and get back. – Stig Kølbæk Jun 10 '21 at 14:07
  • A webhook is basically a page you set up to accept requests and inform the PDFMonkey API where it can be found (in effect a listener). When your page receives data from PDFMonkey it can be processed depending on what you want to do (i.e store to the file system or persist in a db etc.) and cURL is just the same as making an XHR to an remote address as described in the duplicate. None of that requires the involvement of client-side code. – user692942 Jun 10 '21 at 14:32
  • I understand that @user692942, but I believe then that I have not been clear enough in what I am trying to do, and that is totally my bad I can see that now .. I should have been clearer than just "call for a status" What I actually need is to that when a user Push a button it sends the request to PDF monkey, then a "spinner" appears" and a listener is waiting for the status that the PDF is ready, and then request it from their server and display the download link to the user,and at the same time download it to the server and e-mail it to some e-mail address. Thats why I figure I need jQuery? – Stig Kølbæk Jun 10 '21 at 20:30

0 Answers0