cURL Sample – GeneratePrgDocReport.sh for Profitability and Cost Management

Prerequisites: jq http://stedolan.github.io/jq/download/linux64/jq

Common functions: See Profitability and Cost Management Common Helper Functions for cURL.

funcGeneratePrgDocReport() {
        url=$SERVER_URL/epm/rest/$API_VERSION/applications/$APP_NAME/povs/$POV_GROUP_MEMBER1/programDocumentationReport
        echo $url
        curl -G "$url" --data-urlencode 'queryParameter={"fileType":"PDF","stringDelimter":"_","useAlias":"false"}' -u "$USERNAME:$PASSWORD" -o "response.txt" -D "respHeader.txt"
        output=`cat response.txt`
        status=`echo $output | jq '.status'`
        echo $status
    if [ $status == 0 ]; then
        echo "Program Documentation Report generated successfully"
        message=`echo $output | jq '.details'`
        echo $message
    else
        error=`echo $output | jq '.details'`
        echo "Error occurred. " $error
    fi
    funcRemoveTempFiles "respHeader.txt" "response.txt"

}