Alpha Video Training
Page 1 of 2 12 LastLast
Results 1 to 30 of 34

Thread: cURL Xbasic Object

  1. #1
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default cURL Xbasic Object

    I've spent a whole lotta time trying to get a complex API integration underway with the new cURL Xbasic object. But I think I'm stymied on a basic point or two. Right now it appears that I'm not successful in submitting the credentials in the Headers.

    1. Is there any way to look at the object as you build it or otherwise view what's being constructed? If you follow all the examples, you can certainly set all the options, etc. but how to review the output/call so you can maybe see what's wrong?

    2. I need a bunch of stuff in the HTTP Header. So I presume this is OK, for instance:
    Code:
    ce.setOpt("HTTPHEADER", "Content-Type:text/xml")
    ce.setOpt("HTTPHEADER", "charset=utf-8")
    ce.setOpt("HTTPHEADER", "Accept:text/xml")
    ce.setOpt("HTTPHEADER", "SOAPAction: http://www.docusign.net/API/3.0/CreateAndSendEnvelope")
    And, while I'm here, has anyone used cURL (or any Alpha methods) to work with Docusign? I see Scott Binger's given it a run. My client is paying for a bit of tech help from Docusign but so far, no joy here. I do have an idea that if I can see (and share with tech support) what's being emitted/requested then perhaps we can figure out what's wrong.
    -Steve


  2. #2
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,140

    Default Re: cURL Xbasic Object

    I know absolutely nothing about this. However, for your item 2 regarding headers, did you see THIS ? (Especially the very bottom.)

    Excuse me if that has nothing to do with the issue.

    Ray Lyons

  3. #3
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Yeah, I saw all that Ray and have addressed it in every way possible. I've switched to HTTP_Fetch() and am still having problems. APIs can be "interesting" but this one is especially stubborn.
    -Steve


  4. #4
    Member
    Real Name
    Josh Cole
    Join Date
    Jun 2012
    Posts
    678

    Default Re: cURL Xbasic Object

    Steve,

    I'm also working on integrating an alpha app I've built with docusign. I've started down the path of using node js as there is builtin support in alpha. Docusign provides node js Javascript examples and there are a couple videos by Selwyn demonstrating how xbasic can be used with node js

  5. #5
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,140

    Default Re: cURL Xbasic Object

    Quote Originally Posted by Steve Workings View Post
    Yeah, I saw all that Ray and have addressed it in every way possible. I've switched to HTTP_Fetch() and am still having problems. APIs can be "interesting" but this one is especially stubborn.
    Okay, I am totally out of my element here, but for headers would something like the following be of any help? Don't see how it would relate to cURL but maybe?

    Code:
    dim alpha as P
    alpha = http_get("http://www.alphasoftware.com/")
    a5_show_html(alpha.headers)
    If not, either ignore or say "No", and in either case, I'm wasting your time and will stop.

    Ray

  6. #6
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    368

    Default Re: cURL Xbasic Object

    Just looking at what's available from Docusign and their API examples another option would be to compile a .Net assembly in Visual Studio into a DLL and then use Alpha's native ability to call an external .Net library passing the parameters from Alpha. All you would have to do to distribute your app would be to include the DLL in your published files.
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

  7. #7
    Member
    Real Name
    Josh Cole
    Join Date
    Jun 2012
    Posts
    678

    Default Re: cURL Xbasic Object

    I have successfully created the .net integration Steve but I wanted to use xbasic to interface with docusign, there is more control.

    I think the node js option is the best

  8. #8
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Still experimenting. Can't seem to get things rolling with the cURL Xbasic object. So it's an easy switch to http_fetch(). But while that call doesn't work either from Alpha's IDE, Docusign's tech can put the exact text I emit into Postman and it works. If we can figure out what's "different" coming out of the A5 IDE I'll be all set.
    -Steve


  9. #9
    Member
    Real Name
    Josh Cole
    Join Date
    Jun 2012
    Posts
    678

    Default Re: cURL Xbasic Object

    Steve,

    Are you interested in seeing a working node.js solution?

    I feel like I am invisible here : )
    Last edited by coleresources; 05-31-2015 at 08:51 PM.

  10. #10
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Lots of ways to do this Josh. I've already spent a ton of time with the cURL attempt, am within an inch of success using http_fetch() and that's enough for me right now. Sure, I'd like to have this implementation in about 5 different ways, but someone's gotta pay the bills.
    -Steve


  11. #11
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    This really deserves another thread, but going to keep it here anyway. As noted elsewhere, the POST I'm doing with HTTP_Fetch() is returning this error when run from the A5 IDE, but not if you take the same POST and call it with, say, Postman.

    Could not connect to server: WSANO_DATA - Valid name, no data record of requested type while getting host name..

    Detailed Description:
    The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for.
    The usual example for this is a host name-to-address translation attempt (using gethostbyname or WSAAsyncGetHostByName)
    which uses the DNS (Domain Name Server).
    An MX record is returned but no A record—indicating the host itself exists, but is not directly reachable.
    Docusign's tech support says, and some web searches confirm, that this is a Winsock error.

    Here is my POST header:

    Code:
    POST / HTTP/1.1
    Host: https://demo.docusign.net/api/3.0/dsapi.asmx
    Connection: close
    X-DocuSign-Authentication:<stuff here...>
    Content-Type:text/xml 
    charset=utf-8
    Accept:text/xml
    SOAPAction: http://www.docusign.net/API/3.0/CreateAndSendEnvelope
    Content-Length: 348021
    So, anyone know what I need to do?
    -Steve


  12. #12
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    368

    Default Re: cURL Xbasic Object

    Cole, I've been working on a third option which is integrating from Github a docusign API library written in .Net that includes classes and methods to fully interact with the Docusign REST services. I'm stuck on a couple of points at the moment but if I can get it working it should be a fairly elegant way of integrating the DocuSign API into Alpha. In the meantime I'd love to see your NodeJS solution as well. Great opportunity to learn a few tricks that could come in handy down the road.
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

  13. #13
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: cURL Xbasic Object

    Steve,

    I have only minimal experience with http functions. I few years back i did some work on an EDI solution using SOAP. The cause of the problem I had at the time was pointed out to me to be including page information in the 'host:' info. if you checkout the wiki page for http_fetch you will notice that host server and the page to request are specified separately. Checking out some examples of POST on the net in line with your format shows that the 'page' portion goes after the 'POST' keyword and the server is specified by host: and does not include the http

    Try
    Code:
    POST /api/3.0/dsapi.asmx HTTP/1.1
    Host: demo.docusign.net
    Connection: close
    ..............
    ...........
    I don't know how to specify to use https over http though.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  14. #14
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Thanks Tim. I was just starting to fool more with the http_fetch() parameters. If I remove the Host: from the header, I get an error that "Host must be specified."
    -Steve


  15. #15
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: cURL Xbasic Object

    Your welcome Steve. Yes you still need to specify the host. But the host(.host) is just the server address. the resource at that server would go in the '.page' parameter.
    Code:
    dim request as P
    dim response as P
    
    request.host = "demo.docusign.net"
    request.page = "/api/3.0/dsapi.asmx"
    
    response = http_fetch(request)
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  16. #16
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Yes, tried that and many other things. Here's my current Header, but same result:

    Code:
    POST /api/3.0/dsapi.asmx HTTP/1.1
    Host: https://demo.docusign.net
    Connection: close
    X-DocuSign-Authentication:<DocuSignCredentials>...</DocuSignCredentials>
    Content-Type:text/xml 
    charset=utf-8
    Accept:text/xml
    SOAPAction: http://www.docusign.net/API/3.0/CreateAndSendEnvelope
    Content-Length: 348029
    -Steve


  17. #17
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,680

    Default Re: cURL Xbasic Object

    Quote Originally Posted by Steve Workings View Post
    This really deserves another thread, but going to keep it here anyway. As noted elsewhere, the POST I'm doing with HTTP_Fetch() is returning this error when run from the A5 IDE, but not if you take the same POST and call it with, say, Postman.



    Docusign's tech support says, and some web searches confirm, that this is a Winsock error.

    Here is my POST header:

    Code:
    POST / HTTP/1.1
    Host: https://demo.docusign.net/api/3.0/dsapi.asmx
    Connection: close
    X-DocuSign-Authentication:<stuff here...>
    Content-Type:text/xml 
    charset=utf-8
    Accept:text/xml
    SOAPAction: http://www.docusign.net/API/3.0/CreateAndSendEnvelope
    Content-Length: 348021
    So, anyone know what I need to do?
    Yes, it is a Winsock error. And it is not related to the actual POST that you've created. Winsock is complaining that it cannot even resolve the proper IP address for the specified host in order to make the initial connection.

    What exactly are you specifying for the host when you set up your http_fetch() call? It looks like you may be specifying https://demo.docusign.net, and that is a URI, not a host. The host would just be demo.docusign.net

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  18. #18
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,680

    Default Re: cURL Xbasic Object

    The next prerelease will include additional validation in http_fetch() to handle a full URI being provided as a hostname. In this case, it will extract just the hostname from the URI and use it as appropriate.

    -Lenny

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  19. #19
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Thanks Lenny. At least I've been able to change the behavior.

    When I specify the host as "demo.docusign.net", and run this:

    resp = http_fetch(req, .t.)
    showvar(resp)

    I get:

    Body error:
    Code:
    <html><body><h1>400 Bad request</h1>
    Your browser sent an invalid request.
    </body></html>
    and
    headers:
    Code:
    HTTP/1.0 400 Bad request
    Cache-Control: no-cache
    Connection: close
    Content-Type: text/html
    -Steve


  20. #20
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,572

    Default Re: cURL Xbasic Object

    I have successfully created a document, then a template, and then sent it to me for signing, and signed using DocuSign.

    I'm using the REST API and pieced together the requirements for a successful login call and envelope call using a templateid with the XBasic cURL genie and the DocuSign REST API Explorer.

    Although there's a lot of documentation for DocuSign it is, on the whole, kinda terrible. Some of their cURL examples are for V1 and are incomplete or simply just wrong enough to make you wander through their API.

    I'll post it if you want it... but it's not for SOAP. If SOAP or http_fetch() is what you're after then I won't bother. I've read on their site that SOAP, although available, may not be kept up to date... so I woudn't use it.

  21. #21
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    368

    Default Re: cURL Xbasic Object

    In working on the .Net DLL integration I discovered a bug in Alpha's routines that will be fixed in tomorrow's pre-release to allow reading and writing to static properties in a class without a constructor. Once I have that working I believe I'll be able to utilize the library available at: https://github.com/docusign/DocuSign-.NET-Client. It's very full-featured and uses REST connected to the V2 API. I'll let you know what I find once I get the newest update to Alpha.

    Special thanks to Kurt Rayner at Alpha for looking at this issue and correcting the bug in such a timely fashion!
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

  22. #22
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,680

    Default Re: cURL Xbasic Object

    Quote Originally Posted by Steve Workings View Post
    Thanks Lenny. At least I've been able to change the behavior.

    When I specify the host as "demo.docusign.net", and run this:

    resp = http_fetch(req, .t.)
    showvar(resp)

    I get:

    Body error:
    Code:
    <html><body><h1>400 Bad request</h1>
    Your browser sent an invalid request.
    </body></html>
    and
    headers:
    Code:
    HTTP/1.0 400 Bad request
    Cache-Control: no-cache
    Connection: close
    Content-Type: text/html
    Your headers are not valid HTTP/1.1. The format is
    <header_name><colon><single space><header value>

    While some servers may tolerate the missing space after the colon in a couple of your headers, charset=utf-8 will not parse as a proper HTTP header and should result in an error. I suspect what you want is
    Content-Type: text/html; charset=utf-8

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  23. #23
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    368

    Default Re: cURL Xbasic Object

    Okay, with a bit of guidance from Kurt's response I have successfully logged in and sent an envelope using the .Net API. Here's the code necessary to login, fill an envelope with information and link it to a pre-defined template:

    Code:
    dim sv as DotNet::Services
    dim assy as DotNet::AssemblyReference
    assy.FileName=a5.Get_Path()+"\DocuSign.Integration.Client.dll"
    DocuSign_Web_Address="http://demo.docusign.net"
    rs=sv.RegisterAssembly("::",assy)
    
    if rs then
    	'Set the RestSettings properties
    	RestSettings = DocuSign::Integrations::Client::RestSettings::Instance
    	RestSettings.IntegratorKey="YourIntegratorKeyGoesHere"
    	RestSettings.DocuSignAddress=DocuSign_Web_Address
    	RestSettings.WebServiceURL=DocuSign_Web_Address+"/restapi/v2"
    end if
    
    'Create an Account class instance and login
    Dim account as DocuSign::Integrations::Client::Account
    account.Email="YourEmailUsedToRegister@Docusign.Net"
    account.Password="YourDocuSignPassword"
    rs=account.login()
    
    if rs then
    	'Create and send an envelope based on a template
    	Dim envelope as DocuSign::Integrations::Client::Envelope
    	envelope.Login=account
    	envelope.TemplateId="GUID-of-Docusign-Template" 'ID of template in DocuSign
    
    	'Create an array of template roles to attach to the envelope with recipient information - for testing just make it one
    	Dim template_roles[1] as DocuSign::Integrations::Client::TemplateRole
    	template_roles[1].name = "John Doe" ' Recipient name
    	template_roles[1].email = "johndoe@somemail.com" ' Recipient Email
    	template_roles[1].roleName="YourTemplateRole" ' RoleName in template - I used RoleOne for instance
    
    	'Assign the array of recipients to the envelope
    	envelope.TemplateRoles=template_roles
    	envelope.EmailSubject = "DocuSign Alpha Client - Signature Request from Template"
    	envelope.Status = "sent"
    
    	'Attempt to send the email(s)
    	result=envelope.Create()
    
    	if result then 'Successfully sent so show the Envelope ID - we could capture this and use it to view status updates later
    		showvar(envelope.EnvelopeId)
    	end if
    end if
    It's actually pretty simple once you get the initial syntax down. The two tricks were figuring out the syntax to access the RestSettings and creating an array of type TemplateRole to submit to the TemplateRoles property of envelope.
    Last edited by compuaid; 06-01-2015 at 06:11 PM.
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

  24. #24
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Boy we have a lot of topics in this thread. Anyway, Lenny - your suggestion seems to work about the Header. It's not what Docusign documentation shows and it seems to not matter to Postman. But, at least I don't have an error.

    Now I'm trying to figure out what else is going on as I'm getting back a parsed_headers.status_code = 302. This is getting very confusing as it seems now that I have to completely re-construct my request and submit it, but when I do, Docusign complains right away with a "Not Found". This makes less and less sense as I go, and I'm getting crap help so far from their paid tech support.
    -Steve


  25. #25
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Another update. Turns out that http_fetch() and it's resulting 302 response is just a killer. After 3 weeks of trying. cURL doesn't seem to do the job, or at least no one knows how. Glad a couple of you are trying the .NET but I can't use the REST API for various reasons so now I'll have to figure out .NET and and SOAP API.
    -Steve


  26. #26
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    368

    Default Re: cURL Xbasic Object

    Steve, just a question - based on the fact that the SOAP API is older and may not continue to be updated in the future what would force you to go that route rather than the newer and more full-featured REST API? I used the REST API mainly to leverage the full-featured open source .NET library available through Github that's already been written (I hate reinventing the wheel!) I'm sure you can write a similar library for SOAP using the examples provided and simply expose those classes in a "roll your own" DLL and it shouldn't be too difficult but I just was curious as to what kind of circumstances would make REST unusable in an environment.
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

  27. #27
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    I had an initial discussion with their sales and tech, and we all agreed that because their REST API uses OAuth, it is not appropriate for this implementation on an Intranet where Oauth cannot complete its validation. Looking further now I'm not so sure of the accuracy of all those assumptions. But, I'm going to stick with http_fetch() and the SOAP because I got it working last night (er, this morning) after their tech guy mentioned that there's a redirect in the sandbox that's causing the 302 response, and that redirect is not in the final implementation. After a bit more experimenting, I'm on my way now.
    -Steve


  28. #28
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    368

    Default Re: cURL Xbasic Object

    Glad you got it working. Sounds like your tenacity paid off. This has been a good project to try and push the .NET integration capabilities to a bit more of a limit and also a good proof-of-concept use case for pulling in open source libraries and extending the already terrific capabilities of Alpha.
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

  29. #29
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,596

    Default Re: cURL Xbasic Object

    Not working. Nearly 2 days ago I moved my code -- the exact stuff that works on my local PC - to my client's development PC for further development. Haven't been able to succeed a single time from there, despite using the exact same code. I think the clue is in my response.headers which vary substantially between my local success and the new machine failure.

    Successful headers:
    HTTP/1.1 200 OK
    Cache-Control: private, max-age=0
    Content-Length: 3632
    Content-Type: text/xml; charset=utf-8
    X-RateLimit-Reset: 1433383200
    X-RateLimit-Limit: 1000
    X-RateLimit-Remaining: 998
    Date: Thu, 04 Jun 2015 01:22:13 GMT
    Vary: Accept-Encoding
    Connection: close
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    Failed headers:
    HTTP/1.1 500 Internal Server Error
    Cache-Control: private
    Content-Length: 1267
    Content-Type: application/soap+xml; charset=utf-8
    Date: Thu, 04 Jun 2015 01:14:14 GMT
    Connection: close
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    But I have no idea why.
    -Steve


  30. #30
    Member
    Real Name
    Josh Cole
    Join Date
    Jun 2012
    Posts
    678

    Default Re: cURL Xbasic Object

    Steve,

    Is this a windows server operating system? It could be the Internet security settings on the server that are causing the problem. If you have access to the server manager you can disable the restrictive access

    Just a thought

Similar Threads

  1. cURL and Rest API Question for Newsfeed
    By ssmoore1 in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 10-26-2014, 08:08 AM
  2. Convert CURL command to HTTP_POST
    By Scott Kurimski in forum Alpha Five Version 11 - Desktop Applications
    Replies: 6
    Last Post: 02-03-2014, 09:27 AM
  3. Cron & Curl
    By EricN in forum Application Server Version 9 - Web/Browser Applications
    Replies: 5
    Last Post: 08-27-2009, 02:32 AM
  4. RTF object w. xbasic
    By Peter.Greulich in forum Alpha Five Version 8
    Replies: 7
    Last Post: 01-20-2008, 07:29 PM
  5. Xbasic email object
    By kgilroy in forum Alpha Five Version 5
    Replies: 4
    Last Post: 10-01-2002, 10:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •