API documentation for ovpn

Hi I’m triying to use the API for setting up an GL-AR150 which is running 3.017 firmware.

The api documentation at https://dev.gl-inet.com/router-api/1/#api-ovpn-PostOvpnClientAddnew says “Generate an new OVPN client for the configure files uploaded recently” but I haven’t found any api call to upload files to the router.

Can you help me?, please.
Thanks in advance.

Hi
Please user this api :api/ovpn/client/upload

I haven’t found that entry on the API v1 documentation, can you provide additional info about the parameters?
The API v2 reference doesn’t talk about the parameters, is it supposed to store the request body as the uploaded file? It uses the last file uploaded on the same session or the last uploaded file of all sessions?

Hi
V2 version of the API requires firmware above 3.025, upload interface parameters reference screenshot below:

Thanks for your answer, but, while AR150 interface doesn’t show 3.025 as an update for the firmware, I’m working with the 3.017 version, which remains on v1 API.

Download the latest version here:
https://dl.gl-inet.com/firmware/ar150/testing/

Thanks, I was aware of those testing versions, but I need to work with the versions we get from our suppliers here in Spain.

Hi
3.017 API

1 Like

Hi, i need help about using APIs to configure Openvpn remotely.
If someone can please share the complete APis needed and how to build the commands.

mi AR150 is running 3.0.24 FW.

i built the command like this but i am getting error regarding savepath

curl -H “Authorization: WVtVHCZfDlV6DuzmO8F5vX7ftiOA8hFM” --cookie “QSESSIONID=12b11242400e070000” 10.102.0.21/api/ovpn/client/upload -F “name=VPN”;“filename=c:\curl\cert2.zip” -v

and i get this error
{“code”:-5,“msg”:“failed to find savepath”}* Connection #0 to host 10.102.0.21 left intact

Please if someone can help.
Thanks in advance.

Having the same issue! Did you find how to get this working?

Hi Logan,

i have just replied in your post.

I’m doing it using python, but using “file” as the name of the variable, and uploading a openvpn conf file as attachment worked for me.

#Upload the config file.
files = {'file': open('config.ovpn','rb')}
req = s.post(base_url + 'api/ovpn/client/upload', files=files, headers=headers, cookies=cookies)
cookies = dict(req.cookies)
data = json.loads(req.content)
if not data['code'] == 0:
    print("Error uploading file")
    exit(1)

After successfully upload the file, you should call api/ovpn/client/uploadcheck, api/ovpn/client/addnew and api/ovpn/client/set

2 Likes

If you’re trying to accomplish this in C# (RestSharp specifically) it would look something like this…

var fileBytes = File.ReadAllBytes(@"C:\myprofile.ovpn");
var request = new RestRequest("ovpn/client/upload");
request.AddHeader("Authorization", _authToken);
request.AddFile("file", fileBytes, "myprofile.ovpn");
var response = _restClient.Post<BaseResponse>(request);