Use built in function for special FetchSessionKey

This commit is contained in:
Kalle Carlbark 2021-11-27 23:52:51 +01:00
parent 36ba50352a
commit 72862609c5
No known key found for this signature in database

View file

@ -10,6 +10,7 @@ import (
"log"
"net/http"
"net/url"
"strings"
"time"
"github.com/pkg/errors"
@ -198,7 +199,7 @@ func (c *Client) FetchSessionKey(privatekey string) error {
query := form.Encode()
ctx := context.Background()
req, err := c.newRequest(ctx, "POST", secretsPath+"/get-session-key/", "", query)
req, err := http.NewRequestWithContext(ctx, "POST", secretsPath+"/get-session-key/", strings.NewReader(query))
if err != nil {
return err
}
@ -213,6 +214,7 @@ func (c *Client) FetchSessionKey(privatekey string) error {
req.Header.Add("Authorization", " Token "+c.Token)
var sessionkey NetBoxSessionKey
res, err := c.do(req, sessionkey)
if err != nil {
return err