Good morning all,
Back on Xojo after a long absence!
My environment is up to date:
Xojo 2019 r3.2
MBS 20.1
MacOS Mojave 10.14.6
I need to connect to a website that provides an API.
This is what the documentation indicates:
- CONNECTION
POST method
Access url:
https://opendata-rncs.inpi.fr/services/diffusion/login
Entries:
Variables to be entered in the HEADER Characteristics
login User account login (as transmitted when creating your account)
password User account password (custom)
Exits :
Sample response:
{
username logged in
}
So I tried with the object: URLConnection in a window :
Dim TheUrl as String = “https://opendata-rncs.inpi.fr/services/diffusion/login”
TheWebConnection.ClearRequestHeaders
TheWebConnection.RequestHeader(“login:”) = UserName
TheWebConnection.RequestHeader(“password:”) = Pass
TheWebConnection.Send(“POST”, TheUrl )
with corect login and password as I can log to the site with my browser.
I got an422 error :
{
“globalErrors”: [
“login and passwrod don(t match.”
]
}
So I tried with SetRequestContent :
Dim postData as string = “login: “+ “=” + UserName +”&”+ "password: " + “=”+Pass
TheWebConnection.SetRequestContent(postData, “application/x-www-form-urlencoded”)
TheWebConnection.Send(“POST”, TheUrl )
with a 500 error :
“globalErrors”: [
“RestParam not found : class java.lang.String :Header:login”
]
}
I do not understand what is wrong!
If you had an idea it would be greatly appreciated.
Thanks,
Fred