API OpenVPN Upload

curl --location --request POST ‘http://192.168.8.1/cgi-bin/api/ovpn/client/upload’ \

–header ‘Authorization: 689b070fde8f41ab879ee5adb7e3f82d’ \

–form ‘name=myVPN’ \

–form ‘filename=C:\Users\User1\Desktop\client.ovpn’

Trying to use the API v2 to upload a VPN Config but getting failed to find save path msg returned. Do i need to set anything before calling /upload or have i just misunderstood the implementation!

Cheers
Logan

A customer gave me the code below last month, he said it is worked, good luck

curl -X POST -L -H "Authorization: cuC2zrRbHUcEpU2dL1RAA3WoJJJynOxy" --cookie "QSESSIONID=b9093a04d10b020000" 192.168.8.1/api/ovpn/client/upload -F "name:'file';type=application/x-zip-compressed" -F "file=@c:\cert2.zip;type=application/zip"

Hi Logan,

I am the one that gave the info to Leo and i can confirm that it works.
the @ is mandatory, just replace the file location for where you have your file located.

After uploading the file, you need to run the verify API.

Regards,
Juan

2 Likes

Cheers Juan that’s working now. You mention the Verify API (I can only see Uploadcheck in the API docs!). Also it doesn’t list any parameters i need to fed in!

Thanks for any pointers.
Logan.

1 Like

I assume uploadcheck is what you mean and note its a GET not a POST as per the doc. Then i can call AddNew!

Is there a reason this shouldnt work?

curl --location --request POST ‘http://192.168.8.1/cgi-bin/api/ovpn/client/upload’ \

–header ‘Authorization: 91ad52ef9fd24b859531c5942a95249d’ \

–form ‘name:=file;type=application/x-zip-compressed’ \

–form ‘file=@C:\Users\user1\Desktop\client.ovpn;type=application/zip’

Sorry that I don’t know the curl command much.

Hi Logan,

it is uploadcheck the API you should run after the upload.
I was fighting with the firmware API at that time that need the verify after so i messed up.
Regards,
Juan…

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);