REST API knowledge exchange
Post Reply
marco.horstmann
Veeam Software
Posts: 617
Liked: 116 times
Joined: Dec 31, 2014 3:05 pm
Full Name: Marco Horstmann
Location: Hannover, Germany
Contact:

Swift Code Examples?

Post by marco.horstmann »

Hi guys,

I actually try to implement some swift code to access our backup data.
has anybody already build some swift code around our RESTful API?

I was not able to find anything to this.

Thanks
Marco
Marco Horstmann
Senior System Engineer @ Veeam Software

@marcohorstmann
https://horstmann.in
VMware VCP
NetApp NCIE-SAN for 7-Mode and Clustered Ontap
oleg.feoktistov
Veeam Software
Posts: 2021
Liked: 673 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Swift Code Examples?

Post by oleg.feoktistov »

Hi Marco,

Been a while since I used Swift, but here is an example of how to, for instance, get backups via VBR REST API:

Code: Select all

var request = URLRequest(url: URL(string: "https://localhost:9419/api/v1/backups")!,timeoutInterval: Double.infinity)
request.addValue("1.1-rev1", forHTTPHeaderField: "x-api-version")
request.addValue("application/json", forHTTPHeaderField: "Accept")
request.addValue("Bearer <access_token goes here>", forHTTPHeaderField: "Authorization")

request.httpMethod = "GET"

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

I'd advise to try Postman as it will create examples in all sort of languages based on your saved request.
That's basically where I got the sample above from.

Best regards,
Oleg
marco.horstmann
Veeam Software
Posts: 617
Liked: 116 times
Joined: Dec 31, 2014 3:05 pm
Full Name: Marco Horstmann
Location: Hannover, Germany
Contact:

Re: Swift Code Examples?

Post by marco.horstmann »

thx Oleg,

I just playing with it and thought maybe i can build something useful.

Thx for this. It will help me.

Kind regards
Marco
Marco Horstmann
Senior System Engineer @ Veeam Software

@marcohorstmann
https://horstmann.in
VMware VCP
NetApp NCIE-SAN for 7-Mode and Clustered Ontap
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests