Skip to content

Commit

Permalink
fix(metadata): Add collectionId to query params on metadata updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
spbsoluble committed Sep 7, 2024
1 parent ce7f797 commit 301a186
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion v2/api/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ func (c *Client) UpdateMetadata(um *UpdateMetadataArgs) error {
metadata = um.Metadata
}

query := apiQuery{
Query: []StringTuple{},
}

if um.CollectionId > 0 {
query.Query = append(query.Query, StringTuple{"collectionId", fmt.Sprintf("%d", um.CollectionId)})
}

fields, err := c.GetAllMetadataFields()
if err != nil {
return err
Expand Down Expand Up @@ -61,6 +69,7 @@ func (c *Client) UpdateMetadata(um *UpdateMetadataArgs) error {
Endpoint: "Certificates/Metadata",
Headers: headers,
Payload: um,
Query: &query,
}

resp, err := c.sendRequest(keyfactorAPIStruct)
Expand All @@ -69,7 +78,12 @@ func (c *Client) UpdateMetadata(um *UpdateMetadataArgs) error {
}

if resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("[ERROR] Something unexpected happened, %s call to %s returned status %d", keyfactorAPIStruct.Method, keyfactorAPIStruct.Endpoint, resp.StatusCode)
return fmt.Errorf(
"[ERROR] Something unexpected happened, %s call to %s returned status %d",
keyfactorAPIStruct.Method,
keyfactorAPIStruct.Endpoint,
resp.StatusCode,
)
}
return nil
}
Expand Down

0 comments on commit 301a186

Please sign in to comment.