Create ticket with PHP curl (REST)

English! place to talk about OTRS development, programming and coding

Moderator: tto

Post Reply
alessandrO
OTRS newbie
Posts: 1
Joined: 24 Aug 2017, 20:27
OTRS Version?: OTRS 5.0
Real Name: Alessandro Porto
Company: Obsidium

Create ticket with PHP curl (REST)

Post by alessandrO » 24 Aug 2017, 20:46

Good afternoon. I am trying to create a Ticket with PHP Curl (REST) but I am having serious problems to understand this.

1. I NEED TO ACCESS THE VIA ULR SERVICE BUT I'M NOT GETTING IT;
2. I AM CREATING A FORM IN PHP AND I RECEIVE THE DATA CREATING A JSON AND SENDING TO THE WEBSERVICE, THE TICKET SHOULD BE CREATED.
3. HOW TO CONFIGURE THE CURL FOR POST AND GET?
4. WHAT SHOULD BE THE ADDRESS TO ACCESS THE SERVICE?

Tank's

******************************************************
MY CODE
******************************************************

$userpasswd = "username:password";
$url = "http://my URL";
$json = "{\"Ticket\":{\"Title\":\"REST Create Test\", \"Type\": \"Unclassified\", \"Queue\":\"Raw\",\"State\":\"open\",\"Priority\":\"3 normal\",\"CustomerUser\":\"customer\"},\"Article\":{\"Subject\":\"Rest Create Test\",\"Body\":\"This is only a test\",\"ContentType\":\"text/plain; charset=utf8\"}}";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_USERPWD, $userpasswd);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);

curl_close ($ch);

User avatar
sameer615
OTRS newbie
Posts: 37
Joined: 16 Aug 2017, 11:26
OTRS Version?: OTRS 5
Real Name: sameer sardar
Company: ENS

Re: Create ticket with PHP curl (REST)

Post by sameer615 » 11 Sep 2017, 12:40

hey,
if im not wrong , Your requirement is to get ticket in OTRS from an external form , is it ??

so basically you're posting data from that page, is it ??

reneeb
OTRS guru
Posts: 4597
Joined: 13 Mar 2011, 09:54
OTRS Version?: 3.3.x
Company: Perl-Services.de
Contact:

Re: Create ticket with PHP curl (REST)

Post by reneeb » 11 Sep 2017, 22:08

Perl / OTRS development: http://perl-services.de
Free OTRS add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de

Post Reply