API/Python/Open-Source Solutions

Expand all | Collapse all

How to write RESTful web services client based on curl

Jump to Best Answer
  • 1.  How to write RESTful web services client based on curl

    Posted 03-22-2016 04:37:00 AM
    I need to write a RESTful web service client for Delphix.I am new to delphix and RESTful webservices.How can I write a client based on the below curl.

     Create Delphix API Session

    $ curl -s -X POST -k --data @- http://delphix-server/resources/json/delphix/session \&nbsp;&nbsp;&nbsp;&nbsp;-c ~/cookies.txt -H "Content-Type: application/json" <<EOF<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;"type": "APISession",<br>&nbsp;&nbsp;&nbsp;&nbsp;"version": {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "APIVersion",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"major": 1,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"minor": 4,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"micro": 3<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br>EOF
    Delphix Login

    $ curl -s -X POST -k --data @- http://delphix-server/resources/json/delphix/login \&nbsp;&nbsp;&nbsp;&nbsp;-b ~/cookies.txt -H "Content-Type: application/json" <<EOF
    {
    &nbsp;&nbsp;&nbsp;&nbsp;"type": "LoginRequest",
    &nbsp;&nbsp;&nbsp;&nbsp;"username": "delphix_username",
    &nbsp;&nbsp;&nbsp;&nbsp;"password": "delphix_password"
    }
    EOF



    #Masking
    #DemoEnvironment


  • 2.  RE: How to write RESTful web services client based on curl
    Best Answer

    Posted 03-22-2016 07:41:00 AM
    Hi, Simple example with no control points $cat DE_REST_CALL.sh #!/bin/sh export user=delphix_admin export pass=delphix export DE=


  • 3.  RE: How to write RESTful web services client based on curl

    Posted 03-22-2016 01:50:00 PM
    Hey Gundamaiaih, I am not quite sure what you mean by "need to write a restful web services client".

    If you are on Unix/Linux, you can put those curl calls into a shell script.
    If you are on Windows, you can use the curl equivalent and throw that into a powershell script  http://thesociablegeek.com/azure/using-curl-in-powershell/

    If you want something that is universal, then I would suggest using the Delphix Python bindings (you can get that through your Delphix Channel Manager or Sales Rep). This is the suggested course of action for enterprise integration, etc. 



  • 4.  RE: How to write RESTful web services client based on curl
    Best Answer

    Posted 11-04-2018 05:53:00 AM

    # REST powershell

     $Header = @{
        "Accept"="application/json"
        "connectapitoken"="97fe6ab5b1a640909551e36a071ce9ed"
        "Content-Type"="application/json"
      }

     

      $Jason = @{
        "username" = <username>
        "password" = <password>
      } | ConvertTo-Json

    Invoke-RestMethod -Uri "<engine url>:<port>/login" -Method POST -Headers $header -Body $Jason