Author Topic: Get URL Text Error  (Read 1155 times)

0 Members and 1 Guest are viewing this topic.

mastip

  • Mosquito
  • Posts: 1
Get URL Text Error
« on: November 06, 2022, 03:33:54 AM »
Hello Lee Mac I found your lisp Get URL Text  -  Lee Mac in this topic https://www.theswamp.org/index.php?topic=46438.0

I am tryin to use Your function in my lisp to get text from this url https://services.gugik.gov.pl/nmt/?request=GetHbyXY&x=595603.1742775&y=665574.3101856
and use this text as a variable.

This url returns elevation from terrain model on specific coordinates.

Your function works on plain url addres like https://services.gugik.gov.pl/nmt/?request=GetHbyXY&x=595603.1742775&y=665574.3101856.

But there is an error when I am using strcat with variables from getpoint command

Automation Error 80072ee6; [IWinHttpRequest] Error accessing [OPEN] method. ErrIndex=0;
The URL does not use a recognized protocol.

This is part of my lisp.

(defun c:getnmt ( / x y p wys)

  (setq p (getpoint "\nPick Point: "))
  ;;(setq textloc (getpoint "\nPick Label Location: "))
  (setq x (rtos (car p) 2 6))
  (setq y (rtos (cadr p) 2 6))
  (terpri)
  (princ (strcat x " " y))
  (princ)
  (terpri)
  ;;URL EXAMPLE:       https://services.gugik.gov.pl/nmt/?request=GetHbyXY&x=595603.1742775&y=665574.3101856
  (princ (strcat "Check URL"))
  (terpri)
  (princ (strcat "\"" "https://services.gugik.gov.pl/nmt/?request=GetHbyXY&x=" x "&y=" y "\""))
  (terpri)
  (terpri)
  (setq wys (LM:geturltext (strcat "\"" "https://services.gugik.gov.pl/nmt/?request=GetHbyXY&x=" x "&y=" y "\"")))
  (princ wys)
  (princ)
  (terpri)
  (terpri)
  (setq wys (LM:geturltext "https://services.gugik.gov.pl/nmt/?request=GetHbyXY&x=595603.1742775&y=665574.3101856"))
  (princ wys)
  (princ)
)
 
 (defun LM:geturltext ( url / obj rtn )
    (if (setq obj (vlax-create-object "winhttp.winhttprequest.5.1"))
        (progn
            (setq rtn
                (vl-catch-all-apply
                   '(lambda nil
                        (vlax-invoke-method obj 'open "GET" url :vlax-false)
                        (vlax-invoke-method obj 'send)
                        (vlax-get-property  obj 'responsebody)
                    )
                )
            )
            (vlax-release-object obj)
            (if (vl-catch-all-error-p rtn)
                (prompt (vl-catch-all-error-message rtn))
                (vl-list->string
                    (mapcar '(lambda ( x ) (lsh (lsh x 24) -24))
                        (vlax-safearray->list (vlax-variant-value rtn))
                    )
                )
            )
        )
    )
)
« Last Edit: November 06, 2022, 05:31:28 AM by mastip »

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Get URL Text Error
« Reply #1 on: November 07, 2022, 05:45:52 AM »
Code: [Select]
(setq wys (LM:geturltext (strcat "https://services.gugik.gov.pl/nmt/?request=GetHbyXY&x=" x "&y=" y)))