Jump to content
  • 0

Package edit API query fails


msorri

Question

Hi.

When I try to call the Packages\Edit function through the API, it fails with the following error:

{
    "response": null,
    "error": {
        "name": {
            "empty": "Please enter a package name."
        },
        "email_content[0][lang]": {
            "empty": "Please enter a language."
        },
        "pricing[0][currency]": {
            "format": "Currency code must be 3 characters."
        }
    }
}

Here's my code which calls the API:

	public function deactivatePackage($id = null)
    {
        global $blestaapi;
        $response = $blestaapi->put("packages", "edit", array("package_id" => $id, "vars" => array("status" => "restricted")));
        $responseParsed = array("response" => $response->response(), "error" => $response->errors());
        return $responseParsed;
    }

 

I'm quite confused, because it seems that I call the Packages\Add function because it complains about the missing options that are a optional in Packages\Edit but not in Packages\Add.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
On 4/20/2017 at 6:46 PM, msorri said:

Hi.

When I try to call the Packages\Edit function through the API, it fails with the following error:


{
    "response": null,
    "error": {
        "name": {
            "empty": "Please enter a package name."
        },
        "email_content[0][lang]": {
            "empty": "Please enter a language."
        },
        "pricing[0][currency]": {
            "format": "Currency code must be 3 characters."
        }
    }
}

Here's my code which calls the API:


	public function deactivatePackage($id = null)
    {
        global $blestaapi;
        $response = $blestaapi->put("packages", "edit", array("package_id" => $id, "vars" => array("status" => "restricted")));
        $responseParsed = array("response" => $response->response(), "error" => $response->errors());
        return $responseParsed;
    }

 

I'm quite confused, because it seems that I call the Packages\Add function because it complains about the missing options that are a optional in Packages\Edit but not in Packages\Add.

you have sent only the id of the package to edit fucntion, before you should get the package info via Packages.get() then send the data with the changed info you want edit .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...