mozilla-it / bugzilla-kanbanize

Sync Automation between Kanbanize and Mozilla
0 stars 1 forks source link

Convert all key=value request bodies to JSON #40

Open floatingatoll opened 6 years ago

floatingatoll commented 6 years ago

Bugzilla's API formally requires us to transmit JSON in our request bodies. However, Apache has for all eternity been silently converting (non-JSON) key=value request bodies into "magic" that somehow worked — until October 2018, when Apache was replaced and that functionality broke.

Some of our requests use the JSON method, and some use the key=value method. Let's switch them all to the JSON method. For example:

    $req->content("assigned_to=$assigned&token=$BUGZILLA_TOKEN");

    $req->content("reset_assigned_to=true&token=$BUGZILLA_TOKEN");

    $req->content("whiteboard=$whiteboard&token=$BUGZILLA_TOKEN");

    my $content = "status=$status&token=$BUGZILLA_TOKEN";
    if ($status =~ /^(?:RESOLVED|VERIFIED|CLOSED)$/) {
        $content .= "&resolution=$resolution";
    }
floatingatoll commented 6 years ago

I believe we simply need to switch from $content = "key=value&token=$TOKEN"; to $content = encode_json({ key => value, token => $TOKEN }); and that's sufficient to make all this work. I encourage reviewing the Bugzilla REST API docs and asking a BMO team member to look over any patch.