Jump to content

Recommended Posts

Posted

I am trying to modify an existing script to work with a REST API.  My script currently reads ini files that we manully maintane in order to creat a CMD file on the fly to perform some copy task for the Autodesk Revit product.  We are using Revit Server and it has the ability to use a REST GET statement.  I have been look at some of the examples but admit that I am truly lost. 

Would someone be able to in simple terms explain how to get AutoIT to send a GET statement.  I know that with REST I would have the following items I would need to pass but I am just not sure how to start or if it is even possible.

Base URL

http://<host>/RevitServerAdminRESTService2013/AdminRESTService.svc

Request headers

User-Name

User-Machine-Name

Operation-GUID (I know how to generate this)

So my understanding of REST my Get statement would contain something like what I have below

Get /ServerProperties

User-Name: Jcampbell

User-Machine-Name: TestMachine

Operation-GUID: Random generated GUID from the top of my script to help ID my transaction with the REST API.

Thanks for the help and sorry for the basic questions.  I work on this stuff off and on so I get to were I can do it and then leave it for 8 months to a year and end up revisting it and like they say if you dont use it you loose it.

 

Posted

Give a spec for this one RestAPI , and an example what You do.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I know.

When I talk "This One" I mean : Can you give us a shortcut to the relevant documentation, originating site that you want to send / receive data using the REST API.

Beacause description like the

  Quote

 

Request headers

User-Name

User-Machine-Name

Operation-GUID (I know how to generate this)

 

is not accurate.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

On the other hand, we may possibly discuss the problem using a generic service using the REST API.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Hi,

This will work for SOAP requests. I might work for your needs? You would need to modiy this to suit.

Ignore if thisis not useful.

 

Notice the 'setRequestHeader' taking Header name and value

Refer to MSDN also:

http://msdn.microsoft.com/en-us/library/windows/apps/hh453379.aspx

http://msdn.microsoft.com/en-us/library/windows/apps/hh453349.aspx

http://msdn.microsoft.com/en-us/library/windows/apps/hh453367.aspx

        Local $objHTTP = ObjCreate("Microsoft.XMLHTTP")
    Local $objReturn = ObjCreate("Msxml2.DOMDocument.3.0")

    ; Set up to post to the URL
    $objHTTP.open ("post", $sURL, False)

    ; Set a standard SOAP/ XML header for the content-type
    $objHTTP.setRequestHeader ("Content-Type", "text/xml")

    ; Set a header for SOAPAction
    $objHTTP.setRequestHeader ("SOAPAction", $sSOAPAction)

    ; Make the SOAP call
    $objHTTP.send ($sSoapEnvelope)

    ; Get the return envelope
    $strReturn = $objHTTP.responseText

    ; Load the return envelope into a DOM
    $objReturn.loadXML ($strReturn)

    ;return the XML DOM Object (to be filtered/searched)
    Return $objReturn;
Posted

Thanks

but I want something like this:

https://dev.twitter.com/docs/api

of course if You want to send REST to twitter :)

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

even we can practice on Twitter REST API

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Thanks for the input guys.  I worked out what I needed to do.  I was not sending my header information the way it needed to be.  I ended up with something like what is shown below.  <HOST> referes to my server name that is hosting the REST service.

$restReq = ObjCreate("winhttp.winhttprequest.5.1")
$restReq.Open("GET", "http://<host>/RevitServerAdminRESTService2013/AdminRESTService.svc/|ssd testing\01\01 Production\SharedData\Models\Contents", False)

$restReq.setRequestHeader ("User-Name", "Jeff")
$restReq.setRequestHeader ("User-Machine-Name", "B700")
$restReq.setRequestHeader ("Operation-GUID", "1640EA28-0C15-40BF-8DDA-5DB9D917D1F4")

$restReq.Send()

$oReceived = $restReq.ResponseText
$oStatusCode = $restReq.Status

If $oStatusCode == 200 then
 $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
 FileWrite($file, $oReceived)
 FileClose($file)
EndIf

 
 

Posted
I am glad that you were able to solve the problem.
Thank you for sharing your comments with which to solve the problem.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...