Reputation: 45
I hope this is not a question dealing with passing a parameter in a URL.
I have a Put request. The following code adds a user named "Johndoe" in the server. It is NOT like name ?= 'JohnDoe' (not passed as a parameter)
uri = URI.parse('http://localhost:15672/api/users/JohnDoe/')
I would like to have the JohnDoe or any name passed from a function like,
def test_add_user(username,password)
uri = URI.parse('http://localhost:15672/api/users/**username**/')
The username in the URL is the username getting added as a user in the server. I suppose the username is not a URI parameter since the 'name' part looks like a resource to me. I tried the following code but in vain
uri.join('http://localhost:15672/api/users/',username)
Also I tried this
username = 'john/'
uri.join('http://localhost:15672/api/users/',username)
Any fixes or any alternative ideas as to how I can pass the name?
Regards
Karthik
Upvotes: 1
Views: 138
Reputation: 4315
It could be done by interpolation of username
, like this:
uri = URI.parse("http://localhost:15672/api/users/#{username}")
Upvotes: 1