How to write RESTful web services client based on curl

  • 0
  • 1
  • Question
  • Updated 1 month ago
  • Answered
  • (Edited)
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;&quot;version&quot;: {<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


Photo of Gundamaiah A

Gundamaiah A

  • 122 Points 100 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Mouhssine SAIDI

Mouhssine SAIDI

  • 4,862 Points 4k badge 2x thumb
Hi,

Simple example with no control points

$cat DE_REST_CALL.sh

#!/bin/sh

export user=delphix_admin
export pass=delphix
export DE=

get_session {
curl -s -X POST -k --data @- http://${DE}/resources/json/delphix/s... \
-c ~/cookies.txt -H "Content-Type: application/json" <<
Photo of Adam Bowen

Adam Bowen, Official Rep

  • 17,420 Points 10k badge 2x thumb
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. 
Photo of Torben Hansen

Torben Hansen

  • 250 Points 250 badge 2x thumb

# 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