Uncaught PodioBadRequestError: "Must specify either 'embed' or 'url'" - podio

I need to set value for an embed field in Podio, and this is my code:
$field_id='pdf-property-information';
$options=$item->fields[$field_id]->values;
if(empty($options))
$item->fields[$field_id] = new PodioEmbedItemField($field_id);
// Create embed
$embed = PodioEmbed::create(array('url' => $pdf_property_information));
// Set using object
$item->fields[$field_id]->values = $embed;
// Set using associative array
$item->fields[$field_id]->values = array('embed_id' => $embed->embed_id);
And this is the error I get:
Fatal error: Uncaught PodioBadRequestError: "Must specify either
'embed' or 'url'" Request URL: http://api.podio.com/item/826141668
Stack Trace: #0
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/lib/Podio.php(355):
Podio::request('PUT', '/item/826141668', Array) #1
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/models/PodioItem.php(183):
Podio::put('/item/826141668', Array) #2
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/models/PodioItem.php(66):
PodioItem::update(826141668, Array, Array) #3
/home/apibind/public_html/sourcingplatform/trunk/add.php(403):
PodioItem->save() #4 {main} thrown in /podio-php-4.3.0/lib/Podio.php
on line 289

You have to pass the embed_id with array key "embed". Here your final line will be like,
// Set using associative array
$item->fields[$field_id]->values = array('embed' => $embed->embed_id);

Related

Mule 4, get uri params with Anypoint application

I'm new in Mulesoft, I'm following Quickstart guide. In Step 2 (https://developer.mulesoft.com/guides/quick-start/developing-your-first-mule-application), I need to receive variables from URI in this way:
[{'id' : attributes.uriParams.productId}]
But when I try my GET I have the following error in console:
**Message : "Cannot coerce Array ([{id: "2" as String {class: "java.lang.String"}}]) to Object 1| [{'id' : attributes.uriParams.productId}] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Trace: at main (line: 1, column: 1)" evaluating expression: "[{'id' : attributes.uriParams.productId}]". Error type : MULE:EXPRESSION Element : get:\products(productId):test_daniel-config/processors/1 # test6_db_connection:test_daniel.xml:133 (Select) Element XML : SELECT product.,CONCAT('["', (GROUP_CONCAT(variant.picture SEPARATOR '","')),'"]') AS pictures,CONCAT('[', GROUP_CONCAT('{"',variant.identifierType, '":"', variant.identifier, '"}'),']') AS identifiersFROM product INNER JOIN variant ON product.uuid = variant.productUUIDWHERE product.uuid = :id; #[[{'id' : attributes.uriParams.productId}]] *
Any Ideas? Thanks!
cannot coerce Array to object error pop's up when you are using an array where you were supposed to use an object.
in the exception above the uri-param should be treated as ab object i.e. enclosed in {} but its being treated as an array of objects [{}].
this is causing the error.

Fatal error showing

Fatal error: Uncaught Error: Call to undefined function mysqli_result() in /home/prasanth/projects/ishen1/index.php:49 Stack trace: #0 {main} thrown
how to slove this
according to this answer https://stackoverflow.com/a/17707384/8284461 that function is inefficient, you can use mysqli_fetch_assoc() instead. for example:
while($row = mysqli_fetch_assoc($result)) {
$id = $row['ID'];
$name = $row['name'];
etc..
}

Why does Ramda work in this example where native Array.map or Lodash do not?

In the process of writing an example for this SO question, this question came up:
Why does the native Array.map throw an error when used like this:
[tmp1, tmp2].map(fs.createReadStream)
.forEach(stream => stream.pipe(jsonStream));
fs.js:1664
throw new TypeError('"options" argument must be a string or an object');
^
TypeError: "options" argument must be a string or an object
at new ReadStream (fs.js:1664:11)
at fs.createReadStream (fs.js:1649:10)
at Array.map (native)
Similarly with lodash… but it works fine with ramda.
// Same error:
_.map([tmp1, tmp2], fs.createReadStream)
.forEach(stream => stream.pipe(jsonStream));
// Works fine:
R.map(fs.createReadStream, [tmp1, tmp2])
.forEach(stream => stream.pipe(jsonStream));
Note, this is the full code from referenced question:
var fs = require('fs');
var path = require('path');
var JSONStream = require('JSONStream');
var tmp1 = path.join(__dirname, 'data', 'tmp1.json');
var tmp2 = path.join(__dirname, 'data', 'tmp2.json');
var jsonStream = JSONStream.parse();
jsonStream.on('data', function (data) {
console.log('---\nFrom which file does this data come from?');
console.log(data);
});
[tmp1, tmp2].map(p => {
return fs.createReadStream(p);
}).forEach(stream => {
stream.pipe(jsonStream);
});
The second argument of fs.createReadStream should be undefined no?
This is most likely due to Array.prototype.map and _.map passing three arguments to the provided mapping function (the value, the index and the collection), while R.map only passes the value.
In your example, fs.createReadStream is being given the array index as its second argument where it expects an options object or string instead, causing the "options" argument must be a string or an object error. If you want to use Array.prototype.map or _.map in this way, you'll need to wrap the method call in a function to prevent the extra arguments:
[tmp1, tmp2].map(p => fs.createReadStream(p))

Making a delete DAO -> Uncaught exception 'PDOException'

I'm trying to make a dao which can delete a specific item once you click on the X
How did I try this? I'll begin with showing you the DAO:
public function delete($iddelete){
$sql = "DELETE FROM `wanthave`.`wanthave_items` WHERE `wanthave_items`.`id` = `iddelete` = :iddelete LIMIT 1";
$stmt = $this->pdo->prepare($sql);
$stmt->bindValue(':iddelete', $iddelete);
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
}
This is how I setup my if structure in a controller:
if(isset($_GET['iddelete'])){
$this->itemDAO->delete($_GET['iddelete']);
}
Once I click on the X near the item I want to delete it goes to a page with in the end "&iddelete=(id of the item)". So actually when iddelete is set it's going to delete it.
But unfortunately I get this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'iddelete' in 'where clause'' in /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php:56 Stack trace:
#0 /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php(56): PDO->prepare('DELETE FROM `wa...')
#1 /Applications/MAMP/htdocs/wanthave/controller/ItemController.php(198): ItemDAO->delete('89')
#2 [internal function]: ItemController->delete()
#3 /Applications/MAMP/htdocs/wanthave/controller/Controller.php(9): call_user_func(Array) #4 /Applications/MAMP/htdocs/wanthave/index.php(69): Controller->filter()
#5 {main} thrown in /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php on line 56
Line 56 = $stmt = $this->pdo->prepare($sql);
Any help?
public function delete($id){
$stmt = $this->pdo->prepare("DELETE FROM wanthave_items WHERE id = ?");
return $stmt->execute([$id]);
}

Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]:

<?php
include('connect.php');
$date = $_POST['date'];
$student_ID = $_POST['student_ID'];
$full_name = $_POST['full_name'];
$year_section = $_POST['year_section'];
$payment_description = $_POST['payment_description'];
$amount = $_POST['amount'];
$received_by = $_POST['received_by'];
// query
$sql = "INSERT INTO transaction (date,student_ID,full_name,year_section,payment_description,amount,received_by) VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
$q = $db->prepare($sql);
$q>execute(array(':sas'=>$date,':asas'=>$student_ID,':asafs'=>$full_name,':offff'=>$year_section,':statttt'=>$payment_description,':dot'=>$amount,':rd'=>$received_by));
header("location: index.php");
?>
I get the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables
does not match number of tokens' in
C:\xampp\htdocs\recordmanagement\main\reg.php:15 Stack trace: #0
C:\xampp\htdocs\recordmanagement\main\reg.php(15):
PDOStatement->execute(Array) #1 {main} thrown in
C:\xampp\htdocs\recordmanagement\main\reg.php on line 15
In the code I am also unsure about the meaning of these values:
(:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft);
I downloaded it from sourcecode, so it was not written by me.
There seems to be a field to much in the query. This:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
should probably be:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd)";
as there is no matching value for the :ft field.
Whether this is because your missing an item in the values or if it's not needed I can't say.