Skip to content

json: cannot unmarshal object into Go value of type []json.RawMessage #1

@narkan

Description

@narkan

I can't work out how to format the payload. I've tried this:

    include( plugin_dir_path( __FILE__ ) . 'StackPath.php' );
    $stackpath = new StackPath\StackPath( "my-default-stack-38343c", SP_CLIENT_IDZZ, SP_CLIENT_SECRETZZ );


    $response2 = $stackpath->post( "cdn/v1/stacks/my-default-stack-38343c/purge", [
        "json" => [ "items" => [
            "purgeAllDynamic" => true,
            "invalidateOnly" => false,
            "recursive"=>true,
            "url" =>"https://thecommunitychurch.online"
        ] ]
    ] );

But I get the response: "json: cannot unmarshal object into Go value of type []json.RawMessage"

If I remove the json outer wrapper:

    $response2 = $stackpath->post( "cdn/v1/stacks/my-default-stack-38343c/purge", [
        "items" => [
            "purgeAllDynamic" => true,
            "invalidateOnly" => false,
            "recursive"=>true,
            "url" =>"https://thecommunitychurch.online"
        ]
    ] );

the response is "Items must be provided"

If I send it without the "items" wrapper I get the same: "Items must be provided"

    $response2 = $stackpath->post( "cdn/v1/stacks/my-default-stack-38343c/purge", [
            "purgeAllDynamic" => true,
            "invalidateOnly" => false,
            "recursive"=>true,
            "url" =>"https://thecommunitychurch.online"
        
    ] );

Any help would be appreciated ;)

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