i am trying to create task in asana with custom fields data but its gives me fatal error,
if i am not attach custom field it properly task created.
But i want to create task with custom field mean i am also want to custom field data
require 'vendor/autoload.php';
use Asana\Client;
// this is access token
$ASANA_ACCESS_TOKEN = '************************';
$option = array(array(
"id" => "720739169509386",
"name" => "Phone",
"text_value" => "9806130204",
"type" => "text",
),
array(
"id" => "720739169509388",
"name" => "Contact",
"text_value" => "girish",
"type" => "text",
)
);
$client = Asana\Client::accessToken($ASANA_ACCESS_TOKEN);
$me = $client->users->me();
$workspaceId = $me->workspaces[0]->id;
$demoTask = $client->tasks->createInWorkspace($workspaceId, array(
"name" => "demo task created at " . date('m/d/Y h:i:s a'),
"projects" => array('720702522904258'),
'assignee' => 'test#test.com',
'notes' => 'Lorem Ipsum is simply dummy text of the printing and',
'custom_fields' => $option,
));
echo "Task " . $demoTask->id . " created.\n";`
This is the error i am getting:
Fatal error: Uncaught exception 'Asana\Errors\InvalidRequestError' with message 'Invalid Request' in C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Errors\AsanaError.php:39 Stack trace: #0 C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Client.php(77): Asana\Errors\AsanaError::handleErrorResponse(Object(Httpful\Response)) #1 C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Client.php(150): Asana\Client->request('POST', '/workspaces/626...', Array) #2 C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Resources\Gen\TasksBase.php(55): Asana\Client->post('/workspaces/626...', Array, Array) #3 C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\index.php(37): Asana\Resources\Gen\TasksBase->createInWorkspace('626590817891949', Array) #4 {main} thrown in C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Errors\AsanaError.php on line 39
My feeling is that you are trying to create the custom field and the task at the same time aren't you?
Related
I've started writing some code to use SOAP within PHP.
Managed to get my code to login and authenticate, which is a start!
I initially had the following code :
$params = array(
"Parcels" => 1,
"RecipientAddress" => "123 Any Street, Any Town, Anywhere",
"RecipientName" => "Joe Bloggs",
"CollectionDate" => "2019-11-11",
);
// Invoke WS method (Function1) with the request params
$response = $client->__soapCall("GetAvailableServices", array($params));
// Print WS response
var_dump($response);
Which returned the following message :
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Missing Recipient Address Element 'RecipientName' in /home/thisone/public_html/despatchbayservices.php:17 Stack trace: #0 /home/thisone/public_html/despatchbayservices.php(17): SoapClient->__soapCall('GetAvailableSer...', Array) #1 {main} thrown in /home/thisone/public_html/despatchbayservices.php on line 17
I've tried changing the code to :
$params = array(
"Parcels" => 1,
"RecipientAddress" => array(
"RecipientName" => "Joe Bloggs",
),
"CollectionDate" => "2019-11-11",
);
// Invoke WS method (Function1) with the request params
$response = $client->__soapCall("GetAvailableServices", array($params));
// Print WS response
var_dump($response);
Which returned this :
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'RecipientAddress' property in /home/thisone/public_html/despatchbayservices.php:18 Stack trace: #0 /home/thisone/public_html/despatchbayservices.php(18): SoapClient->__soapCall('GetAvailableSer...', Array) #1 {main} thrown in /home/thisone/public_html/despatchbayservices.php on line 18
I'm sure I'm doing something really stupid but I just cant see it - any help massively appreciated!
Sussed it - thanks to Don't Panic for pointing me toward the WDSL.
For reference the correct/working code is :
$params = array(
"Parcels" => array(
"ParcelType" => array(
"Weight" => 5,
"Length" => 5,
"Width" => 5,
"Height"=> 5,
)
),
"RecipientAddress" => array(
"RecipientName" => "Joe Bloggs",
"RecipientAddress" => array(
"CompanyName" => "My Company",
"Street" => "123 Any Street",
"Locality" => "Anywhere",
"TownCity" => "Any Town",
"County" => "Somewhere",
"PostalCode" => "TS23 4EA",
"CountryCode" => "GB",
)
),
"CollectionDate" => "2019-11-11",
);
// Invoke WS method (Function1) with the request params
$response = $client->__soapCall("GetAvailableServices", array($params));
I am new to codeigniter I am trying to save my record into the database and when ever I try to do so it gives me this error.
Fatal error: Uncaught ActiveRecord\UndefinedPropertyException: Undefined property: Product->Array in C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php on line 514 in C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php:514 Stack trace: #0 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php(333): ActiveRecord\Model->read_attribute('Array') #1 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Validations.php(573): ActiveRecord\Model->__get('Array') #2 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Validations.php(141): ActiveRecord\Validations->validates_uniqueness_of(Array) #3 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php(1048): ActiveRecord\Validations->validate() #4 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php(784): ActiveRecord\Model->_validate() #5 C:\xampp\htdocs in C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php on line 514
The code I have wrote works fine for other models. Here is the code I am using.
$data = array(
"type" => $this->input->post('type'),
"code" => $this->input->post('code'),
"name" => $this->input->post('name'),
"category" => $this->input->post('category'),
"cost" => $this->input->post('cost'),
"description" => $this->input->post('description'),
"tax" => $this->input->post('tax'),
"alertqt" => $this->input->post('alertqt'),
"price" => $this->input->post('price'),
"color" => $this->input->post('color'),
"supplier" => $this->input->post('supplier'),
"unit" => $this->input->post('unit'),
"taxmethod" => $this->input->post('taxmethod'),
"options" => $this->input->post('options'),
"photo" => $image,
"photothumb" => $image_thumb,
"created_at" => $date,
"modified_at" => $date
);
$product = Product::create($data);
I have solved it the issue was not in the controller but it was in the model. I was validating uniqueness of array but actually it was not needed. Removing that block of code works fine.
When we are calling Uber Products API, its working perfect but when we call Ride Reminder API, we getting following 404 errors:
PHP Fatal error: Uncaught exception GuzzleHttp\Exception\ClientException
with message
Client error: POST https://sandbox-api.uber.com/v1.2/reminders
resulted in a 404 Not Found response:
404 page not found in
/var/www/html/uber/uber/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /var/www/html/uber/uber/vendor/guzzlehttp/guzzle/src/Middleware.php(65):
GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request),
Object(GuzzleHttp\Psr7\Response))
#1 /var/www/html/uber/uber/vendor/guzzlehttp/promises/src/Promise.php(203):
GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /var/www/html/uber/uber/vendor/guzzlehttp/promises/src/Promise.php(156):
GuzzleHttp\Promise\Promise::callHandler(1,
Object(GuzzleHttp\Psr7\Response), Array)
#3 /var/www/html/uber/uber/vendor/guzzlehttp/promises/src/TaskQueue.php(47):
GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#4 /var/www/html/uber/uber/vendor/guzzlehttp/promises/src/Promise.php(246):
Guzzle in
/var/www/html/uber/uber/vendor/stevenmaguire/uber-php/src/Client.php
on line 173
We are using following sample code to work out, let me know what could be issue.
<?php
include "vendor/autoload.php";
$client = new Stevenmaguire\Uber\Client(array(
'access_token' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'server_token' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'use_sandbox' => true, // optional, default false
'version' => 'v1.2', // optional, default 'v1.2'
'locale' => 'en_US', // optional, default 'en_US'
));
$products = $client->getProducts(array(
'latitude' => '41.85582993',
'longitude' => '-87.62730337'
));
var_dump($products);
$attributes = array(
'reminder_time' => '1429294463',
'phone_number' => '555-555-5555',
'event' => array(
'time' => '1515750429',
'name' => 'John with friends',
'location' => 'Dolores Park',
'latitude' => '37.759773',
'longitude' => '-122.427063',
'product_id' => "737d4e43-9e12-4a81-add3-acb101bab4c7",
),
);
$reminder = $client->createReminder($attributes);
var_dump($reminder);
Please help us to fix this.
Documentation is removed for ride reminders from http://developer.uber.com and they are not currently supported.
I am trying to follow this tutorial, and I need to do it in PHP, so I have to use Elasticsearch-php. In this particular step, I am trying to set up a mapping for elasticsearch and also bulk index data from a .json file. So I looked into examples here and [here][3], and following is my code.
The problem is taht it gives me
Elasticsearch PHP client created successfully!
Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [dynamic]"}],"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [dynamic]"},"status":400} in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:610 Stack trace: #0 /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(273): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array) #1 /var/www/html/Tests/Test/vendor/react/promise/src/FulfilledPromise.php(25): Elasticsearch\Connections\Connection->Elasticsearch\Connections\{closure}(Array) #2 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(Object(Closure), NULL, NULL) #3 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/ in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 610
and when I comment out the line "dynamic" => "false", I get
Elasticsearch PHP client created successfully!
Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected a simple value for field [properties] but found [START_OBJECT]"}],"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected a simple value for field [properties] but found [START_OBJECT]"},"status":400} in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:610 Stack trace: #0 /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(273): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array) #1 /var/www/html/Tests/Test/vendor/react/promise/src/FulfilledPromise.php(25): Elasticsearch\Connections\Connection->Elasticsearch\Connections\{closure}(Array) #2 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(O in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 610
What am I missing? How should I fix this?
<?php
require_once("vendor/autoload.php");
use Elasticsearch\ClientBuilder;
$esClient = ClientBuilder::create()->build();
echo "Elasticsearch PHP client created successfully!<br>";//check
$indexParams = array();
$indexParams['index'] = "test_packets_index";
$indexParams['type'] = "testPacketsType";
$indexParams['body'] = [
'mappings' => [
"testPacketsType" => [
//"dynamic" => "false",
"properties" => [
"timestamp" => [
"type" => "date"
],
"layers" => [
"properties" => [
"ip" => [
"properties" => [
"ip_ip_src" => [
"type" => "ip"
],
"ip_ip_dst" => [
"type" => "ip"
]
]
]
]
]
]
]
]
];
$jsonFileHandle = fopen("packets.json", "r");
if ($jsonFileHandle) {
while ( ($line = fgets($jsonFileHandle)) !== FALSE ) {
if ( !($line == "") ) {
$indexParams['body'][] = json_decode($line, true);
}
}
}
fclose($jsonFileHandle);
#print_r($indexParams['body']);//check
$indexingResponse = $esClient->bulk($indexParams);
echo "Result: "; print_r($indexingResponse); echo "<br>";//check
?>
[3]: https : //www.elastic.co/guide/en/elasticsearch/client/php-api/current/_indexing_documents.html
I read the documentation where there are PHP examples to insert data in a dynamicDB table using AWS SDK. However this is for tabular data. I am trying to insert JSON data i.e. Key Value pair where value is a JSON document. How do I do that ?
I tried the following code from the doc but it does not work unless value is an array.
<?php
require '/home/ubuntu/vendor/autoload.php';
use Aws\DynamoDb\DynamoDbClient;
$client = DynamoDbClient::factory(array(
'profile' => 'default',
'region' => 'ap-southeast-1',
'version' => '2012-08-10'
));
$id = "key";
$value = '{"subKey":"value"}'
$result = $client->putItem(array(
'TableName' => 'myTable',
'Item' => array(
'key' => $value
)
));
It gave me following error
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Found 2 errors while validating the input provided for the PutItem operation: [Item][key] must be an associative array. Found string(1) "2" [Item][userId] must be an associative array. Found string(18) "{"subKey":"value"}"' in /home/ubuntu/vendor/aws/aws-sdk-php/src/Api/Validator.php:38 Stack trace: #0 /home/ubuntu/vendor/aws/aws-sdk-php/src/Middleware.php(78): Aws\Api\Validator->validate('PutItem', Object(Aws\Api\StructureShape), Array) #1 /home/ubuntu/vendor/aws/aws-sdk-php/src/AwsClient.php(208): Aws\Middleware::Aws\{closure}(Object(Aws\Command)) #2 /home/ubuntu/vendor/aws/aws-sdk-php/src/AwsClient.php(202): Aws\AwsClient->executeAsync(Object(Aws\Command)) #3 /home/ubuntu/vendor/aws/aws-sdk-php/src/AwsClient.php(167): Aws\AwsClient->execute(Object(Aws\Command)) #4 /var/www/html/dynamoDB.php(25): Aws\AwsClient->__call('putItem', Array) #5 /var/www/html/dynamoDB.php(25): Aws\DynamoDb\DynamoDbClient->putItem(Array) #6 {main} thrown in /home/ubuntu/vendor/aws/aws-sdk-php/src/Api/Validator.php on line 38
DynamoDB requires you specify the AttributeValue types with the request. Here is the example from https://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-dynamodb.html:
$result = $client->putItem(array(
'TableName' => 'errors',
'Item' => array(
'id' => array('N' => '1201'),
'time' => array('N' => $time),
'error' => array('S' => 'Executive overflow'),
'message' => array('S' => 'no vacant areas')
)
));
For your example try adding DynamoDB types:
$result = $client->putItem(array(
'TableName' => 'myTable',
'Item' => array(
'key' => array('S' => $value)
)
));
Where 'S' could be replaced with 'N', 'B', 'SS', 'NS', 'BS', 'M', 'L', or 'BOOL' as defined here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html#DataModel.DataTypes