Uploading images using the REST API from PHP
Does anyone at - he had success with the download of the images through the Eloqua Rest API using PHP?
I have the final point, but I can't understand what kind of information needs to go the variable $data.
That's what I currently have:
<? PHP
ini_set ("display_errors", 1);
include("..) /.. ("/ eloquaRequest.php");
$eloquaRequest = new EloquaRequest ('Instancename', 'username', 'password', 'https://secure.eloqua.com/API/REST/1.0');
$data = new stdClass();
$data-> image = file_get_contents("./easy.jpg");
$data-> name = 'this is a file name ";
$data-> filename = "luke.jpg";
$data-> contentType = "image/jpeg";
$response = $eloquaRequest-> message (' assets/image/content', $data);
var_dump ($Response);
The error I get is the following, but I think that it is a standard response, if your image does not go through correctly:
Array (1) {[0] = > object (stdClass) #3 (2) {["type"] = > string(9) "FileError" ["requirement"] = > object (stdClass) #4 (3) {["type"] = > string (15) "SizeRequirement" ["maxSize"] = > int (52428800) ["minSize'] = > int (1)}}}
Thank you
Hi Phil,
I had to find that it all the time, it took me several hours. I hope that it allows you to save a headache.
Eloqua is very strict in dealing with the content-type header; See the comment here for a little explanation; REST API - download Images
So what you need to do in PHP, is to build the query string for the image of yourself. You can do as follows (to adapt to your needs, not yet tested);
<>
[...]
$img_path = '. / easy.jpg';
$img_info = getimagesize ($img_path);
$img_real = realpath ($img_path);
$data = "-ELOQUA_BOUNDARY\r\n".
' Content-Disposition: form-data; name =-"Filedata\"; filename =------"".baseName ($img_real). » \"\r\n ».
"Content-Type: '. '" $img_info ['mime']. "" \r\n ".
"\r\n".
file_get_contents() ($img_real). "" \r\n ".
' - ELOQUA_BOUNDARY - ';
$headers = array ("Content-Length:".strlen ($data),"Content-Type: multipart/form-data;") Boundary = ELOQUA_BOUNDARY");
$response = $eloquaRequest-> post (' assets/image/content', $data, $headers);
?>
I have also adapted/reconstructed library Eloqua PHP in order to support the "BOLD" part. You must change the executeRequest function and add something like this to support change the request headers;
curl_setopt ($this-> ch, CURLOPT_HTTPHEADER, $headers);
Tags: Marketers
Similar Questions
-
Upload images using the file API
I am trying to download pictures using the SDK file, but my images are corrupted during the download. Anyone know the correct way to do this? Here are some of my code:
var imgVars = getUrlVars(itemDetails['Picture']); //use image id from query string to build new filename var localImgFilename = '/images/equipment/used/' + imgVars['id'] + '.jpg'; var imgProxy = 'https://[domainwithheld].com/jpg_proxy.php'; //download equipment image from proxy server $.ajax(imgProxy, { 'type': 'GET', 'data': { fetch: itemDetails['Picture'] } }).done(function(result) { if(result) { //upload the image to BC filesystem var f = BCAPI.Models.FileSystem.Root.file(localImgFilename); var imgData = result; f.upload(imgData).done(function () { console.log("Image upload complete."); }).fail(function (jqXHR) { console.log("Upload failed."); }); } }).fail(function() { console.log("Download from proxy failed."); });
You were right! I finally realized that by using the method of jQuery $.ajax to retrieve the image was my problem: it doesn't have the capacity for a binary response. I got it working by simply using a native XMLHttpRequest object with the value 'blob' responseType property for the image and then passing the answer directly in the SDK download method.
Here is an excerpt now simplified my code:
var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if ( this.readyState === 4 && this.status === 200 ) { var localImgFilename = '/images/equipment/used/' + imgURL.split('/').pop(); var f = BCAPI.Models.FileSystem.Root.file(localImgFilename); f.upload(this.response).done(function () { //image uploaded } } } xhr.open('GET', imgProxy + '?fetch=' + encodeURIComponent(imgURL)); xhr.responseType = 'blob'; xhr.send();
-
Using the REST API to delete the contact from the contacts list
Hello world
I am looking for some info for the creation of a request to delete a contact from a list of Contact using the REST API. Here's what I have in Java where the contact id is 1 'and my list is 72'. I'm open to responses in Java, c# or other languages.
serverAddress = new URL ("https://secure.p03.eloqua.com/API/REST/1.0/assets/contact/list/72");
establish communication stuff
connection = null;
Set up the initial connection
connection = (HttpURLConnection) serverAddress.openConnection ();
connection.setRequestMethod ("PUT");
connection.setRequestProperty ("content-type", "json; charset=utf-8 ");"
connection.setRequestProperty ("authorization", 'Basic BLOCKED');
String body = '{\"membershipDeletions\":[\"1\']}";
connection.setDoOutput (true);
connection.getOutputStream () .write (body.getBytes ("UTF8"));
connection.setReadTimeout (10000);
Connection.Connect ();
When I test with it I get a '400' HTTP response
Thank you!
Hi Noel,
The following document describes the operations available for lists of contacts in the Rest API. Please note that we also have a project open source c# example illustrates the use of these endpoints.
Repositories are all available to the public on Github. Hope this helps and please let me know if you need more information.
Thank you
Fred
-
Get the 500 error trying to create a table using the REST API
Hello
I tried to create a table using the REST API for Business Intelligence Cloud, but I got 500 Internal Server Error for a while now.
Here are the details that I use to create a table.
and the json to create the schema that I use is
[{'Nullable': [false], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ["ROWID"]}]
, {'Nullable': [true], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ['RELATIONID']},
{'Nullable': [true], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ['ID']}
, {'Nullable': [true], 'defaultValue': 'dataType' [null],: ['TIMESTAMP'], 'precision': [0], 'length': [0], 'columnName': ['RESPONDEDDATE']},
{'Nullable': [true], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [255], 'columnName': ['RESPONSE']},
{'Nullable': [false], 'defaultValue': 'dataType' [null],: ['TIMESTAMP'], 'precision': [0], 'length': [0], 'columnName': ['SYS_CREATEDDATE']},
{'Nullable': [false], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ['SYS_CREATEDBYID']},
{'Nullable': [false], 'defaultValue': 'dataType' [null],: ['TIMESTAMP'], 'precision': [0], 'length': [0], 'columnName': ['SYS_LASTMODIFIEDDATE']},
{'Nullable': [false], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ['SYS_LASTMODIFIEDBYID']},
{'Nullable': [false], 'defaultValue': 'dataType' [null],: ['TIMESTAMP'], 'precision': [0], 'length': [0], 'columnName': ['SYS_SYSTEMMODSTAMP']},
{'Nullable': [false], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [10], 'columnName': ['SYS_ISDELETED']},
[{'Nullable': [true], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [50], 'columnName': ['TYPE']}]
I tried this using postman and code, but I always get the following response error:
Error 500 - Internal server error
Of RFC 2068 Hypertext Transfer Protocol - HTTP/1.1:
10.5.1 500 internal Server Error
The server encountered an unexpected condition which prevented him from meeting the demand.
I am able to 'get' existing table schemas, delete the tables, but I'm not able to make put them and post operations. Can someone help me to identify the problem, if there is no fault in my approach.
Thank you
Romaric
I managed to create a table successfully using the API - the only thing I see in your JSON which is different from mine is that you have square brackets around your values JSON where I have not. Here is my CURL request and extract my JSON file (named createtable.txt in the same directory as my CURL executable):
curl u [email protected]: password UPDATED h x ' X-ID-TENANT-NAME: tenantname ' h ' Content-Type: application/json '-binary data @createtable.txt https://businessintell-tenantname.analytics.us2.oraclecloud.com/dataload/v1/tables/TABLE_TO_CREATE k
[
{
'columnName': 'ID',
'dataType': 'DECIMAL ',.
'Length': 20,.
"accuracy": 0.
'Nullable': false
},
{
'columnName': 'NAME',
'dataType': 'VARCHAR ',.
'Length': 20,.
"accuracy": 0.
'Nullable': true
},
{
"columnName': 'STATUS."
'dataType': 'VARCHAR ',.
'Length': 20,.
"accuracy": 0.
'Nullable': true
},
{
"columnName': 'CREATED_DATE."
'dataType': 'TIMESTAMP '.
'Length': 20,.
"accuracy": 0.
'Nullable': true
},
{
'columnName': 'UPDATED_DATE ',.
'dataType': 'TIMESTAMP '.
'Length': 20,.
"accuracy": 0.
'Nullable': true
}
]
-
Is there a way to get the data for submission of form of eloqua using the REST API?
I was wondering if there is a way to get the data for submission of form of eloqua using the REST API?
Thank you
On the page that egan related, there is a 'RawData' field for FormSubmit activities. In this area, the raw sending the form query string is returned.
Whatever it is, you can get this info from the activities of the API block, or the endpoints data Rest API.
-
How to set the time to preview using the REST Api of the assembler
Hi all
Using the REST API of the assembler, I can't feature "set the time to preview" to trigger a specific model that fires only at a specific time
This is the format that I'm trying:
http://xxxx:8006 / assembler/json/pages/home? Endeca_Time = 2020-04 - 05 T 14:30
I use the correct format? This is the url parameter listed in the documentation of the Assembly
Thank you
It turns out that the documentation is wrong
- In assembler.properties (service\WEB-INF) of your REST API, you must define
- User.State.Ref = previewUserState
- You use Endeca_date and not Endeca_Time in the URL (documentation is wrong)
- Coding varies from a browser (you may need to URL encode the date in Firefox)
Example:
http://xxxx:8006 / assembler/json/pages/home? Endeca_date = 2020-01 - 11 T 18:00
The date format is: YYYY-MM-dd' you HH: mm
- In assembler.properties (service\WEB-INF) of your REST API, you must define
-
vRO package import/export using the REST API, but what to rebuild a package?
Hello
I can export and import a package using the REST API. The package consists of all the workflows in a certain folder of the project.
That's fine, but when we do another workflow example in the folder of our project, it is not automatically part of the package. This reduces the value of planning an export of it, because it would still this manual interaction.
Is there a way to do it (automate/CLI/REST /...) this?
Thank you!
Ed
Hello
REST API for package management (adding/removing items to package, rebuild a package, etc.) are planned for the next version of vRO - vRO 7.1 (or whatever the COMP version it gets).
-
Workflow of vCO of query using the REST API in PowerShell
Hello
I am interrogating a workflow vCO by name using the REST API of PowerShell based on this article:
http://www.vcoteam.info/articles/learn-VCO/268-how-to-use-the-rest-API-to-start-a-workflow.html
$username = "XXXXXX".
$upassword = "XXXXXX".
$auth = $username + ':' + $upassword
$Encoded = [System.Text.Encoding]: UTF8. GetBytes ($auth)
$EncodedPassword = [System.Convert]: ToBase64String ($Encoded)
$headers = @{' authorization '=' basic $($EncodedPassword) ' ;}}
$body = "<-xmlns = execution context" ". ' http://www.VMware.com/VCO ' > < / execution context > '
#query for workflow named "donothing".
Invoke-RestMethod-uri https://XXXX:8281/api/flow /? conditions = name = donothing -Headers $headers - body $body - ContentType "application/xml" - Get method
Invoke RestMethod: failed to send a content-body with this type of verb.
On line: 1 char: 1
+ Call-RestMethod-uri https://XXXX:8281/api/flow /? conditions = name = donoth ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: NotSpecified: (:)) [invoking-RestMethod], ProtocolViolationException)
+ FullyQualifiedErrorId: System.Net.ProtocolViolationException, Microsoft.PowerShell.Commands.InvokeRestMethodCommand
The request succeeds by using the customer REMAINS on Firefox, but I can't make it work on PowerShell. (NOTE: PowerShell workflow execution works very well)
Any help is appreciated.
Thank you
Juan.
OK, I managed to do work by removing
[System.Net.ServicePointManager]: ServerCertificateValidationCallback = {$true}
And add this at the beginning of the script
"Add-type @ '.
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy: {ICertificatePolicy
public bool CheckValidationResult)
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {}
Returns true;
}
}
"@
[System.Net.ServicePointManager]: CertificatePolicy = New-Object TrustAllCertsPolicy
Now I can use the GET method:
$ret = Invoke-WebRequest - uri $URL - Headers $headers - ContentType "application/xml" - Get method
I spent to Invoke-WebRequest so I can get the return of application Web.
Juan.
-
How do to identify the documents called "models of library" using the RESTful API?
How do to identify the documents called "models of library" using the RESTful API? Furthermore, what constitutes a document to be a "model of library"? I see nothing in the libraryDocuments RESTful documentation that describes this type of document, such as presented on the tab 'Manage' my developer account. Please see the screenshot below. There is a model of Document named "[DEMO ONLY] Test model" listed under "Library Templates" and I try to figure out which classifies that document to be included this way and how does produce a similar announcement by using the RESTful API.
Thank you!
Hello
You can connect to access library models using the REST API, use 'GET /libraryDocuments' allowing to recover documents in library for a user. Models are created in the account of EchoSign, which later are accessible via the REST method mentioned above.
Jat
-
Run the workflow using the SOAP API with PHP
Hello
I'm trying to integrate workflow from code PHP using the SOAP API to Orchestrator.
<? PHP
Try
{
$parameters = array (username = > "username", password = > "passwd");
$client = new SoapClient ('https://vcoserver:8281 / vco/vmware-vmo-webcontrol/webservice?) WSDL "); "
$result = $client-> getAllWorkflows ($parameters);
foreach ($result as $item)
{
foreach ($item as $work)
{
echo $work-> name;
echo "< br >".
echo "id";
echo $work-> id;
echo "< br / > ';
}
}
}
catch (Exception $e)
{
echo $e;
}
? >
I do not see errors/exceptions, but don't see any output as well.
Am I missing something?
Could you use
print curl_error($curl);
After curl_exec to check if there are errors?
If there is an error in SSL certificate, as ' SSL certificate problem: unable to get local issuer certificate ", you can either install certificates roots (Google it for more information how to do), or disable checking of certificates by peers in CURL with something like:"
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
-
I'm trying to use the API to get the signature of all the users of the system fields. I can see this information in the web browser if I go to settings-> user management-> and selecting the user.
I would like to know if there is a way to get the information General information (Signature fields) using the API.
Thank you!
Hi Sai,
The REST API exposes the user records (see the following document); However, signature fields are not included. We need to work on this addition to the API (in a later version), but the option is currently not available.
Please let me know if you have any questions or would like more information.
Thank you
Fred
-
Cannot add firewall rules using the REST API vShield App
Hi all
I get the following error
"< errors > < error > < code > 100039 < / code > < description > Unmatched rules found in the configuration." "< / description > < / error > < / errors >.
When you use the App API vSheild:
POST https:// /API/2.0/app/firewall/dvportgroup-55/config < vsm-ip >
Paylod XML:
<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"? >
< VshieldAppConfiguration >
< firewallConfiguration = "dvportgroup-55" the contextId >
< layer3FirewallRule disabled = "false" priority = "none" id = "1021" >
< action > allow < / action >
< connected > false < / connected >
< source >
< address >
< ipAddress > 172.30.68.212 < / ipAddress >
< / address >
< > 222 portInfo < / portInfo >
< / source >
< destination >
< address >
< ipAddress > 172.30.68.166 < / ipAddress >
< / address >
< application >
< > 333 portInfo < / portInfo >
< Protocol > 6 < / Protocol >
< / application >
< / destination >
< / layer3FirewallRule >
< / firewallConfiguration >
< / VshieldAppConfiguration >Is anyone has seen this before or any idea why this might be happening?
In addition, create a wall of fire to provide the variable "id"... How do I know which id to use to create a new firewall rule. I'm using id = "1021" I see one last created after quesrying API... but when you call it through automation, what will the process to define an id invalid?
Thank you
xar
ID must be present, for the new rule Id must be '0' while that for others it should kept as what. The reason for this error which I believe is the same. Replacement of 1021 with 0 should solve this problem. http://blogs.VMware.com/security/2011/11/using-the-VShield-API.html should also be useful to start with vShield firewall App REST API.
-Kone
-
Access catalog getting and setting using the REST API
I have a catalog I can see through the user interface which allows members to add in the tab share read-only, read/write or full control of the vCD. They do not appear anywhere that I can find when obtaining the catalog through the REST API.
The REST API of 1.5 of vCloud Director documentation indicates that it supports the getting or setting user access to catalogs by using the link "conrolAccess". This link does not appear in the response to a GET the href of the catalog (admin or his substitute). Attempted to add "/ controlAccess" HREF catalogue translated by RESOURCE_NOT_FOUND.
Hello
Could be a bug in the documentation, try like this
https://cloud/api/org/org-uuid/catalog/catalog-uuid/controlAccess - Fetch (GET)
https://cloud/api/org/org-uuid/catalog/catalog-uuid/action/controlAccess - updated (AFTER)
Kind regards
Rajesh Kamal. -
Perspective and visitors to the information using the REST API
According to this post (Eloqua graphics API), visitors and prospects information is not available with the Eloqua REST API.
With the Eloqua REST API there is a field that indicates whether a contact is a prospect or visitor?
Hi Raghu,
There is a new endpoint API (available with the Summer of Eloqua version), which allows you to retrieve a visitor profile.
Please find some information on its use here: Eloqua API REST - recovery of visitor profiles
T.J.
-
As noted below this picture was originally part of a group and the second image is the best quality, I could do after editing it.
This image was originally part of a group of images, but we didn't need all the other images, with that we just need this one when I cropped on the other images and resized is the quality of the image, I found myself
wwhen you say you cropped one out I think that, for me, it looks like you cropped in Photoshop or other photo software. This image looks like it's probably a file AI that you can modify and access to any size you want using Adobe Illustrator.
Maybe you are looking for
-
IdeaPad Y560 dvd drive ide or sata?
Is Y560 dvd drive ide or sata? I want to replace it with a hard drive so I need an IDE HDD is ide?
-
for some reason any fax keeps saying no response when the person on the other end said they receive faxes, there is a NOTE: Image on fax send report is set to off an image of page 1 will appear here for faxes sent as scan and fax... also must there b
-
Failed to read DivX AVI on Windows Media Center
I recently set up Windows Media Center on my Vista Home Premium SP1 Dell inspiron 1720 to try to distribute multimedia content for my new Xbox 360 Elite. He agreed with success the extender of the Xbox, but on the Xbox video files and photo show as e
-
sharing files between computers
I tried to set up a homegroup. On my laptop it shows my other computer, but on my desktop it doesn't. Can someone tell me what to do to fix this?
-
Help and advice please. My computer is a three-in-one ASUS it is stuck in start MODE of Partition Master?