Skip to content

[BUG] output is a mixture of JSON and debug #8

@grahampugh

Description

@grahampugh

A recent change in API Utility is making the output more difficult to parse. As an example:

"$jamfapi" --path /api/v1/managed-software-updates/update-statuses --target myserver 
[retrieve] service: jamfapi-environments
[retrieve] service: https://myserver.jamfcloud.com
{
  "results" : [

  ],
  "isPaged" : true,
  "totalCount" : 0
}

Previous versions would just output the JSON, meaning we can just run a command like the following to then parse the JSON:

json_output=$("$jamfapi" --path "$endpoint" "${args[@]}")

or

"$jamfapi" --path "$endpoint" "${args[@]}" > "$temp_file"

This is no longer possible as the output contains a mixture of debug statements and json.

I was able to workaround it by use of a more complex command:

"$jamfapi" --path "$endpoint" "${args[@]}" 2>&1 | grep -v '^\[retrieve\]' > "$temp_file"

However, I'm concerned that other lines could potentially be outputted that don't start with [retrieve].

Please can you add a -q|--quiet function for those who need to parse the results, or revert the behaviour to the original and add a -v|--verbose option for those who don't need to parse the results? Alternativaly, allow the JSON to be outputted to a file with a -o|--output option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions