How to write RESTful web services client based on curl

  • 0
  • 1
  • Question
  • Updated 7 months 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"

Photo of Gundamaiah A

Gundamaiah A

  • 122 Points 100 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Mouhssine SAIDI

Mouhssine SAIDI

  • 6,126 Points 5k badge 2x thumb

Simple example with no control points



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

  • 21,126 Points 20k 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

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 = @{


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

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