You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You have filled out every section below. Issues without sufficient information are more likely to be closed.
Issue Description
PHP Delete and Update Objects are getting bad request error.
So when i was in parse.com this was no issue at all. But now I get the error bad request when i try to delete destroy() an object or even update it!
This is the code in php that i used to have and in parse.com.
<?php
//session_start();
require '../../vendor/autoload.php';
require '../../PHPcondectionParam.php';
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParsePush;
use Parse\ParseUser;
use Parse\ParseInstallation;
use Parse\ParseException;
use Parse\ParseAnalytics;
use Parse\ParseFile;
use Parse\ParseCloud;
use Parse\ParseClient;
date_default_timezone_set('UTC');
try {
$user = ParseUser::logIn("admin", "password");
$name = $_POST['name'];
$description = $_POST['description'];
$foodOrDrink = $_POST['foodOrDrink'];
$idEvent = $_POST['idEvent'];
$idMagaziou = $_POST['idMagaziou'];
$rating = $_POST['rating'];
$date = $_POST['date'];
$time = $_POST['time'];
echo '<br>';
echo 'date : '.$date;
echo '<br>time : '.$time;
echo '<br>';
$dd = $date.' '.$time;
$dateTime = new DateTime($dd);
$NewmyDate2 = $dateTime->format("Y-m-d\TH:i:s\Z");
$NewmyDate = new DateTime($NewmyDate2);
echo '<br>NewmyDate : ';
print_r($NewmyDate);
$query = new ParseQuery("Event");
$query->equalTo("objectId", $idEvent);
$question = $query->first();
$conDelquery = new ParseQuery("eventController");
$conDelquery->equalTo("idEvent", $question);
$resultsss = $conDelquery->find();
echo "Will be deleted : ".count($resultsss)." results from eventController";
echo '<br>';
for ($i = 0; $i < count($resultsss); $i++) {
$objectDel = $resultsss[$i];
try {
$objectDel->save();
$objectDel->destroy();
echo '<br> Destroy in class eventController with ID : '.$objectDel->getObjectId().' is DONE!';
} catch (ParseException $ex) {
echo 'Failed to save image file, with error message: ' . $ex->getMessage();
}
}
if(!empty($_POST['check_list'])) {
foreach($_POST['check_list'] as $check) {
$TypeEvent = new ParseQuery("TypeEvent");
$TypeEvent->equalTo("EventName", $check);
$questionTypeEvent = $TypeEvent->first();
$NewEventConObj = new ParseObject("eventController");
$NewEventConObj->set("eventDate",$NewmyDate);
$NewEventConObj->set("foodOrDrink",$foodOrDrink);
$NewEventConObj->set("eventRating",intval($rating));
$NewEventConObj->set("eventType", $questionTypeEvent);
$NewEventConObj->set("idEvent",$question);
try {
$NewEventConObj->save();
echo '<br> New object created with objectId: ' . $NewEventConObj->getObjectId();
} catch (ParseException $ex) {
echo 'Failed to create new object, with error message: ' . $ex->getMessage();
}
echo "<br>";
echo $check." : ".$questionTypeEvent->getObjectId(); //echoes the value set in the HTML form for each checked checkbox.
echo "<br>"; //so, if I were to check 1, 3, and 5 it would echo value 1, value 3, value 5.
echo "Event ID : ".$question->getObjectId()."<br>"; //in your case, it would echo whatever $row['Report ID'] is equivalent to.
}
}
print_r ($_FILES['imageEvent']['name']);
echo "<br>";
if(file_exists($_FILES['imageEvent']['tmp_name']) || is_uploaded_file($_FILES['imageEvent']['tmp_name'])) {
$file = ParseFile::createFromData( file_get_contents( $_FILES['imageEvent']['tmp_name'] ), $_FILES['imageEvent']['name'] );
try {
$file->save();
$question->set("poster",$file);
echo '<br> Save file and poster in class Event is DONE!';
} catch (ParseException $ex) {
echo 'Failed to save image file, with error message: ' . $ex->getMessage();
}
}
$question->set("name", $name);
$question->set("description", $description);
try {
$question->save();
echo '<br> Save in class Event is DONE!';
} catch (ParseException $ex) {
echo 'Failed to update your Event, with error message: ' . $ex->getMessage();
}
} catch (ParseException $error) {
echo $error;
// The login failed. Check error to see why.
}
?>
Αnd the echo results are the following
date : 2016-09-30
time : 23:30
NewmyDate : DateTime Object ( [date] => 2016-09-30 23:30:00.000000 [timezone_type] => 2 [timezone] => Z )
Will be deleted : 1 results from eventController
Failed to save image file, with error message: Bad Request
New object created with objectId: oPI6rPmF77
Live : QncKK8M1bV
Event ID : irvvOq6wOF
2.jpg
Save file and poster in class Event is DONE!Failed to update your Event, with error message: Bad Request
In the tables Events and eventController i have ALC to write and update only for the user admin as I login in the first line.
The eventController Class has a pointer to Events class.
Any idea why is this happening as soon as i transfered it to my Server and was not happening when i was in Parse.com??
Expected Results
Update Object inside Event Class, Delete and Save new object in eventController Class.
Actual Outcome
Save new object in eventController Class, without deleteting the previous one and without updating the object in Event Class.
Environment Setup
Server
parse-server version (Be specific! Don't say 'latest'.) : [2.2.22]
Operating System: [CentOS]
Hardware: [don't know exactly]
Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): [Remote]
Database
MongoDB version: [v3.0.12]
Storage engine: [mongo]
Hardware: [same]
Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): [Remote]
Logs/Trace
You can turn on additional logging by configuring VERBOSE=1 in your environment.
Just for your info. In this case i get the error when my hosting service enabled SSL for the Port that i'm making the connection with the parse server. When I change the url from https to http it works fine.
Don't know why though!
Issue Description
PHP Delete and Update Objects are getting bad request error.
So when i was in parse.com this was no issue at all. But now I get the error bad request when i try to delete
destroy()
an object or even update it!This is the code in php that i used to have and in parse.com.
Αnd the echo results are the following
In the tables
Events
andeventController
i have ALC to write and update only for the useradmin
as I login in the first line.The
eventController
Class has a pointer toEvents
class.Any idea why is this happening as soon as i transfered it to my Server and was not happening when i was in Parse.com??
Expected Results
Update Object inside Event Class, Delete and Save new object in eventController Class.
Actual Outcome
Save new object in eventController Class, without deleteting the previous one and without updating the object in Event Class.
Environment Setup
Logs/Trace
You can turn on additional logging by configuring VERBOSE=1 in your environment.
The text was updated successfully, but these errors were encountered: