Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Create New Ticket using API - not configured URL

I'm trying to use the API to create a new ticket using the script at http://osticket.com/forum/discussion/9303/valid-api-key-required-trying-to-create-a-ticket-via-api ;

However I'm stuck with the response from the script that says "You have not configured this script with your URL!" 
I cant see whats wrong. Using: 'url'=>'http://support.mydomain.com/api/http.php/tickets.json'  If I make up a incorrect url or take out the "http.php", the script says the API key is invalid so I am assuming it must recognise in part the url???

The files listed in this folder are:
/public_html/api/.htaccess
/public_html/api/api.inc.php
/public_html/api/cron.php
/public_html/api/error_log
/public_html/api/http.php
/public_html/api/index.php
/public_html/api/pipe.php

Any suggestions please?

v1.8.1.2

Comments

  • Thanks for your response ntozier. 

    I had used that and its a very useful article.  However I have got one step further now as what i had done was replace all instances of your.domain.tld which in line 23 I now realise was used to veryify that the URL had in fact been changed in line 18!

    So now what i get is right to the end of the script line 89 "Unable to create ticket: Valid API key required"

    I checked the api key, as inserted only in line 19, is actually what is listed as an api in ost (tried a couple apis). I checked the ip address used in the api key setup and that is correct. Also selected both  "Can Create Tickets (XML/JSON/EMAIL)" and "Can Execute Cron" 

    Re the ip address, would it be a problem if the script is being called from a shared server (hostgator)?

    Any further ideas? I think its a great feature and would look forward to getting this working to take enquiries from a  web site form.
  • and yes the IP address used for api is the ip address of the server where the request is coming from ( that is where the script is being tested) .
  • Wondering if this provides any clues as to why the api to create a new ticket is not working....
    When using the api email piping feature for incoming emails, I need to change /api/pipe.php : 
    - from "#!/usr/bin/php -q" to "#!/opt/php53/bin/php -q"
    - Make  executable chmod 755 

    so flying blind I played around with a number of permissions and for the http.php file:
    755: Unable to create ticket: Valid API key required
    644: Unable to create ticket: Valid API key required
    777: Unable to create ticket:        + ERROR 500 - INTERNAL SERVER ERROR

    any clues please??
  • Have you tried the comment in the ost-api-example.php?

    # NOTE: some people have reported having to use "http://your.domain.tld/api/http.php/tickets.json" instead.

  • yes have tried using http.php   
  • anymore thoughts?
    v1.9.1
  • I have not installed 1.9.1 yet, so nope.  Have you actually tried: http://your.domain.tld/api/http.php/tickets.json?
    Because your answer said http.php.

    Are you using mod_rewrite or mod_redirect etc?
  • I apologise I'm not a coder but have a very basic knowledge that has enabled me to manage ost thus far, so if you are able to help with padding out a bit more info that would be much appreciated. (eg I'm not familiar with reference to .tld and what is or where is tickets.json  plus your reference to mod_rewrite or mod_redirect??, so I dare say this must be my missing link???) Here's an extract from the code I used (replacing my domain with mydomain.com):

    // You must configure the url and key in the array below.
    
    $config = array(
            'url'=>'http://support.mydomain.com/api/http.php/tickets.json',  // URL to site.tld/api/tickets.json
    		'key'=>'264ED201BD4E06B5D1D459078F5CAA87'  // API Key goes here
    );
    

    Thanks for any further details you can provide...
  • .tld is an abbreviate for top level domain.  i.e. .org, .com, .net etc. Your snippet appears to be correct.

    mod_rewrite or mod_redirect are web server tools (modules) that allow people to redirect from A to B, or re-write the URL in the broswer from domain.tld/osticket to tickets.domain.tld (which really I would think people would use DNS to do.. but... /shrug)  If you don't know then chances are you're not.

    Have you also tried:
    http://your.domain.tld/api/tickets.json
  • No ideas.  You should consult your PHP error logs and see if there is anything there. You should check and make sure that your API key is correct.  And make sure that the traffic is actually coming from where you think it is.
  • - no errors in php error log
    - api in ost API key is same as entered in test script  (mydomain.com/test2.php) - as above
    - IP address of API Key is same as results from "ping mydomain.com" 

    Has anyone else been able to successfully use the API?


  • Has anyone been able to successfully use the API or had similar problems?
  • I have been able to successfully do the API integration of OSTicket with Yii.

    If anyone is interested I will prepare a solution for you.

  • Geo99M6Z, I've come to a dead end so I'd certainly appreciate a solution if you could please. 
  • ntozier, does this give any clues...  

    the domain of my ost is support.mydomain.com  (mydomain of course replacing my actual domain)

    if I put that address in a browser it responds with "URL not supported" 
    If I use http://mydomain.com/api/tickets.json it goes to my domain web site (tho page not found)

    So is this an issue because its a subdomain? 


  • infotec, i have the same problem like you now.

    i use 1.9.8.1

    followed all advice given above, 
    API key is generated using the correct IP address.

    browser (IE/Chrome) result is always "Unable to create ticket: Valid API key required"

    any solution to share please?



  • infotec, i'm NOT using subdomain, i use v1.9.8.1 in a sub-folder.

    I tried both:
    api/tickets.json
    api/http.php/tickets.json

    I still get browser error "URL not supported". So i don't think subdomain is the issue.
    my browser (IE/Chrome) result is always "Unable to create ticket: Valid API key required"
  • If you are getting "Unable to create ticket: Valid API key required" then the system doesn't appear to like the API key that you are using.
  • edited July 2015
    i followed the steps to create API Keys under Admin > Manage > API Keys
    i've tried create 2 different API keys but still the script failed.

    i've also added below 3 lines to check. all values are correct and OK.
    echo $_SERVER['REMOTE_ADDR'] . "<br>";
    echo $config['url'] . "<br>";
    echo $config['key'] . "<br>";

    i have no idea why it fails in our installation.
    API-keys.png
    974 x 545 - 22K
  • I dont know, but this thread is for a different version then you are running so if you are having an issue you really should have started your own thread instead of zombie-ing one from 2014.

    Whats the IP of where the request is being originated from?
    Is that the IP that you used to make your key?
  • oh noted.

    yes. the IP address used to create API Keys is the IP address of my laptop broadband connection which initiate the HTTP request.

    They are same as $_SERVER['REMOTE_ADDR']
  • Did you ever solve this? If so, how?
  • Anyone solve this ?
  • Good Morning,
    I'm also trying to use api.
    You could solve the problems reported in the forum?

    Thank you
  • zombie thread from 2014.
    Killing it with a head shot.
    (closing thread)
    If you have an issue please start your own thread.
This discussion has been closed.