Home Forums Traccar API PHP Integration Accept header missing

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #234
    AnkitaAnkita
    Participant

    Hi james
    I am using you Traccar PHP API for fetching the data of Traccar in PHP. The issue is that I am unable to get the data sometimes. I checked the traccar official forum and found that we need to pass Accept header. Then I see that $jsonA is declared but not being used in the CURL function.
    (private static $jsonA=’Accept: application/json’;)

    Can you give me idea how can I include Accept header in API so that data can be fetched properly.

    #235
    AnkitaAnkita
    Participant

    I am getting below error:

    Device access denied - SecurityException (PermissionsManager:194 < DeviceResource:81 < ...)

    • This reply was modified 3 months, 1 week ago by James JosephJames.
    #236
    James JosephJames
    Keymaster

    Hi,

    Could you please share which function are you calling?

    If you could share both your code, and the api files code for the function you are calling it would help!

    • This reply was modified 3 months, 2 weeks ago by James JosephJames.
    #238
    AnkitaAnkita
    Participant

    Hi James
    I am getting below issue in position and positions function both.
    Device access denied – SecurityException (PermissionsManager:194 < PositionResource:89 < …)

    private static $jsonA='Accept: application/json';
    private static $jsonC='Content-Type: application/json';
    public static function positions($sessionId){
    	$data = '';
    	return self::curl('/api/positions?'.$data,'GET',$sessionId,'',array());
    }
    
    public static function position($sessionId,$id){
    	
    	$data='id='.$id;
    	
    	return self::curl('/api/positions?'.$data,'GET',$sessionId,'',array());
    }
    • This reply was modified 3 months, 1 week ago by James JosephJames.
    #241
    James JosephJames
    Keymaster

    1. The error you shared “device access denied” has nothing to do with the headers, check your session and permissions for that!

    2. If you would like to include an header, you can always do so as shown in the example below ( I have added the “self::$jsonA” part.)

    public static function positions($sessionId){
    	$data = '';
    	return self::curl('/api/positions?'.$data,'GET',$sessionId,'',array(self::$jsonA));
    }
    • This reply was modified 3 months, 1 week ago by James JosephJames.
    • This reply was modified 3 months, 1 week ago by James JosephJames.
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.