Forum

Notifications
Retirer tout

api

8 Posts
2 Utilisateurs
0 Reactions
8,911 Vu
(@sayef1)
Posts: 6
Active Member
Début du sujet
 
[#3558]

im using the api and im trying to post a new ticket but i get this problem with APIKEY each time
"error":"invalid API query", "message":"'data' is not correctly encoded for method POST. Request for correct API KEY"

I get the APIKEY that im using from the user interface :
API key :
468603bfe3148716bc9d1adba2a11355
Send information to the user


 
Posté : 2 Août PM 18:088
(@babynus)
Posts: 14952
Membre Admin
 

Look at old format User Manual (PPT format), available on download page.
You'll find exemples for API.


 
Posté : 3 Août PM 16:088
(@sayef1)
Posts: 6
Active Member
Début du sujet
 

yes im using it , GET work just fine i have this problem with POST and APIKEY for encruption
this is the error i get "Request for correct API KEY"
i get the api key that im using from the "environmental parameters" --> "users" is that the correct path ?


 
Posté : 4 Août PM 14:088
(@babynus)
Posts: 14952
Membre Admin
 

Yes, you must use The API Key of the user that connects through the API.


 
Posté : 4 Août PM 16:088
(@sayef1)
Posts: 6
Active Member
Début du sujet
 

i did use it but i keep getting the same error
{"error":"invalid API query", "message":"'data' is not correctly encoded for method POST. Request for correct API KEY"}
is it possible that the problem with the data format not the apikey ?


 
Posté : 4 Août PM 17:088
(@babynus)
Posts: 14952
Membre Admin
 

Yes, it is possible that your json format is incorrect, this will generate this error message.
Thry with simple json data or for instance, try and request first for a given object (GET) to retreive template format.


 
Posté : 8 Août PM 12:088
(@sayef1)
Posts: 6
Active Member
Début du sujet
 

the correct dictionary for posting:?
-1:{"identifier":"id", "items":[{"id":"1", "reference":"1-INC-1", "name":"slide", "idTicketType":"16"........"nameTargetComponentVersion":"", "result":""}] }
-2 its juste
{"id":"1", "reference":"1-INC-1", "name":"slide", "idTicketType":"16"........"nameTargetComponentVersion":"", "result":""}


 
Posté : 8 Août PM 19:088
(@babynus)
Posts: 14952
Membre Admin
 

Both should work.
(I just tested and it really seems that both work...)
NB : take care to correctly encode your data to avoid unexpected characters. For instance, have a look at htmlEncodeJson() in projeqtor code 😉

Here are two exemples that works with POST action :

{"identifier":"id", "items":[{"id":"1", "reference":"001-001-INC-1", "name":"OK I CHNAGED NAME", "idTicketType":"16", "nameTicketType":"Incident", "idProject":"2", "nameProject":"project one - maintenance", "externalReference":"", "idUrgency":"2", "nameUrgency":"Urgent", "creationDateTime":"2011-09-01 12:00:00", "idUser":"1", "nameUser":"admin", "idContact":"", "nameContact":"", "originType":"", "originId":"", "refName":"bug: it does not work DOES IT ?", "idTicket":"", "nameTicket":"", "idContext1":"", "nameContext1":"", "idContext2":"", "nameContext2":"", "idContext3":"", "nameContext3":"", "idProduct":"", "nameProduct":"", "idComponent":"", "nameComponent":"", "idOriginalProductVersion":"1", "nameOriginalProductVersion":"wa V1.0", "idOriginalComponentVersion":"", "nameOriginalComponentVersion":"", "description":"

test pmlouf

", "idActivity":"", "nameActivity":"", "idStatus":"8", "nameStatus":"re-opened", "idResolution":"", "nameResolution":"", "idResource":"3", "nameResource":"project manager", "idCriticality":"1", "nameCriticality":"Low", "idPriority":"1", "namePriority":"Low priority", "initialDueDateTime":"2011-09-02 18:00:00", "actualDueDateTime":"2011-09-09 18:30:00", "plannedWork":"0.00000", "realWork":"0.00000", "leftWork":"0.00000", "handled":"0", "handledDateTime":"", "done":"0", "doneDateTime":"", "solved":"0", "idle":"0", "idleDateTime":"", "cancelled":"0", "idTargetProductVersion":"", "nameTargetProductVersion":"", "idTargetComponentVersion":"", "nameTargetComponentVersion":"", "result":"

dans leau 

"}] }

{"apiResult":"OK", "apiResultMessage":"Ticket #1 updated", "id":"1", "reference":"001-001-INC-1", "name":"OK I CHANGED AGAIN", "idTicketType":"16", "nameTicketType":"Incident", "idProject":"2", "nameProject":"project one - maintenance", "externalReference":"", "idUrgency":"2", "nameUrgency":"Urgent", "creationDateTime":"2011-09-01 12:00:00", "idUser":"1", "nameUser":"admin", "idContact":"", "nameContact":"", "originType":"", "originId":"", "refName":"OK I CHNAGED NAME", "idTicket":"", "nameTicket":"", "idContext1":"", "nameContext1":"", "idContext2":"", "nameContext2":"", "idContext3":"", "nameContext3":"", "idProduct":"", "nameProduct":"", "idComponent":"", "nameComponent":"", "idOriginalProductVersion":"1", "nameOriginalProductVersion":"wa V1.0", "idOriginalComponentVersion":"", "nameOriginalComponentVersion":"", "description":"

test pmlouf

", "idActivity":"", "nameActivity":"", "idStatus":"8", "nameStatus":"re-opened", "idResolution":"", "nameResolution":"", "idResource":"3", "nameResource":"project manager", "idCriticality":"1", "nameCriticality":"Low", "idPriority":"1", "namePriority":"Low priority", "initialDueDateTime":"2011-09-02 18:00:00", "actualDueDateTime":"2011-09-09 18:30:00", "plannedWork":"0.00000", "realWork":"0.00000", "leftWork":"0.00000", "handled":"0", "handledDateTime":"", "done":"0", "doneDateTime":"", "solved":"0", "idle":"0", "idleDateTime":"", "cancelled":"0", "idTargetProductVersion":"", "nameTargetProductVersion":"", "idTargetComponentVersion":"", "nameTargetComponentVersion":"", "result":"

dans leau 

"}


 
Posté : 8 Août PM 20:088
Share:
Retour en haut