Skip to content

Commit 6db7da4

Browse files
authored
fix: HTTP response handling in SyncJamfProtectPlans (#782)
1 parent 56e95d2 commit 6db7da4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

sdk/jamfpro/jamfproapi_jamf_protect.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,17 @@ func (c *Client) GetJamfProtectPlans(params url.Values) (*ResponseJamfProtectPla
225225
func (c *Client) SyncJamfProtectPlans() error {
226226
endpoint := fmt.Sprintf("%s/plans/sync", uriJamfProtect)
227227

228-
var errorResponse SharedResourcResponseError
229-
resp, err := c.HTTP.DoRequest("POST", endpoint, nil, &errorResponse)
230-
if err != nil {
231-
return fmt.Errorf(errMsgFailedUpdate, "sync Jamf Protect plans", err)
228+
resp, _ := c.HTTP.DoRequest("POST", endpoint, nil, nil)
229+
if resp == nil {
230+
return fmt.Errorf("failed to sync Jamf Protect plans: no response received")
232231
}
233232

234-
if resp != nil && resp.Body != nil {
233+
if resp.Body != nil {
235234
defer resp.Body.Close()
236235
}
237236

238-
// Check if the response contains errors
239-
if errorResponse.HTTPStatus != 0 {
240-
return fmt.Errorf("failed to sync Jamf Protect plans: HTTP %d - %+v", errorResponse.HTTPStatus, errorResponse.Errors)
237+
if resp.StatusCode != 204 {
238+
return fmt.Errorf("failed to sync Jamf Protect plans: unexpected status code %d", resp.StatusCode)
241239
}
242240

243241
return nil

0 commit comments

Comments
 (0)