How to pass payload to Bitbucket api to enable Yaac(yet another commit checker) using Python

54 Views Asked by At

I am trying to enable YAAC (Yet another commit checker) using Bitbucket api programatically (Python 3.7), but somehow the payload looks not good and getting status code as 400, with an error expected a valid value (number, String, array), "exceptionName":"org.codehaus.jackson.JsonParseException""

Can someone please help me out here?

import requests

def stash_status():

    headers = { "Authorization": f'Bearer token',
                "Accept": "application/json",
                "Content-Type": "application/json" }

    payload {
            "key": "com.isroot.stash.plugin.yacc:yaccHook",
            "name": "Yet Another Commit Checker",
            "type": "PRE_RECEIVE",
            "description": "Yet Another Commit Checker pre-receive hook",
            "configFormKey": "com.isroot.stash.plugin.yacc:yaacHook-config-form",
            "scopeTypes": [
                "REPOSITORY",
                "PROJECT"
                ],
            "enabled": "true",
            "configured": "true",
            "scope" {
                "type": "REPOSITORY",
                "resourceld": resourceld
            }}

    response = requests.put(
                    "https://${GITURL}/rest/api/latest/projects/${projectName}/repos/${repoName}/settings"
                    "/hooks/com.isroot.stash.plugin.yacc:yaccHook/enabled", verify=False, headers=headers, data=payload)

    print(response.status_code) 
    print(response.content)

stash_status()
0

There are 0 best solutions below