Jump to content

Is it possible to have a LV Webservice web resource with a variable in the middle of the URL?


Recommended Posts

Specifically - I am looking at emulating an existing REST api that is in the style:

 

/command1/command2/<variable>/command3-related-to-variable

one example where this occurs is with network devices port or VLAN ids  (eg:   <url>/port/3/speed    )

Obviously if it is my REST api,  I could just do /port/speed and have a variable passed for the port number  (eg:   /port/speed?port=3 ) -- but I don't get to define everyone's API... 

In my case, I am trying to emulate such behavior, so I need to setup a web resource that (ideally) would behave identically to the API,  hence  /port/3/speed  etc   is desired.  But I see no obvious way to do so in LV (2024 SP3)

Edited by bobenose
Link to comment

Answered:  https://www.ni.com/docs/en-US/bundle/labview/page/understanding-url-mappings-and-query-strings-in-web-services-real-time-windows.html?srsltid=AfmBOopGM5Aom7rH3ofPKKWSHNo1Ye6RrmFtwG6Zh_QJFtInuTGsTOJO

Future me (or you) - simply set the Web Service Properties ->  HTTP Method VI settings -> URL Mapping  to something such as  <base url>/path1/path2/:variable1/path3/:variable2 )   and variable1 and variable2 will be passed into the VI as a path parameter rather than the query parameter (eg:  <base url>/path1/path2/path3/?variable1=___&variable2=_____ )

  • Thanks 2
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.