Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] Re: CoPersonRole creation via REST fails

Subject: COmanage Developers List

List archive

[comanage-dev] Re: CoPersonRole creation via REST fails


Chronological Thread 
  • From: Scott Koranda <>
  • To: comanage-dev <>
  • Subject: [comanage-dev] Re: CoPersonRole creation via REST fails
  • Date: Sat, 2 Mar 2013 15:57:31 -0600
  • Authentication-results: sfpop-ironport07.merit.edu; dkim=pass (signature verified)

On Sat, Mar 2, 2013 at 3:40 PM, Scott Koranda
<>
wrote:
> Hi,
>
> When I try to create a CoPersonRole via the REST API it fails
> with this:
>
> 403 CO Does Not Exist
>
> This error is being thrown in checkRestPost() in
> AppController.php in this clause:
>
> if($this->requires_co && !isset($this->cur_co)) {
> // If a CO is required and we didn't find one,
> // bail
>
> $this->restResultHeader(403, "CO Does Not Exist");
> return(false);
> }
>
> Yes, I am sure it is there in that clause and not the one
> above it.
>
> The CoPersonRole model does have requires_co set, but I have
> looked through beforeFilter() and add() at all levels in the
> controllers (CoPersonRoleController, StandardController, and
> AppController) and I don't see how the CO could be set during
> a REST call.
>
> The API doesn't include a CoId. I tried putting one in just in
> case but that didn't work.
>
> I think the right place to fix this is in checkRestPost(), but
> I am not sure.
>
> Please advise...
>
> Scott

Hi,

I changed this clause in checkRestPost()

if(!isset($this->cur_co)) {
$coid = -1;

if(isset($reqdata['CoId']))
$coid = $reqdata['CoId'];

to be

if(!isset($this->cur_co)) {
$coid = -1;

if(isset($reqdata['CoId']))
$coid = $reqdata['CoId'];

if(isset($reqdata['CouId'])) {
$this->loadModel('Cou');
$found = $this->Cou->findById($reqdata['CouId']);
$coid = $found['Cou']['co_id'];
}

That is, if there is a CouId in the data sent in to the REST API, use
it to find the CoId since there is one and only one Co for each Cou
(right?).

Let me know if this is satisfactory.

For now, it worked...

Thanks,

Scott



Archive powered by MHonArc 2.6.16.

Top of Page