Forum

Notifications
Clear all

api

8 Posts
2 Users
0 Reactions
8,913 Views
(@sayef1)
Posts: 6
Active Member
Topic starter
 
[#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


 
Posted : 02 Aug 2016 18H01
(@babynus)
Posts: 14952
Member Admin
 

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


 
Posted : 03 Aug 2016 16H50
(@sayef1)
Posts: 6
Active Member
Topic starter
 

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 ?


 
Posted : 04 Aug 2016 14H04
(@babynus)
Posts: 14952
Member Admin
 

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


 
Posted : 04 Aug 2016 16H32
(@sayef1)
Posts: 6
Active Member
Topic starter
 

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 ?


 
Posted : 04 Aug 2016 17H04
(@babynus)
Posts: 14952
Member 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.


 
Posted : 08 Aug 2016 12H52
(@sayef1)
Posts: 6
Active Member
Topic starter
 

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":""}


 
Posted : 08 Aug 2016 19H10
(@babynus)
Posts: 14952
Member 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 

"}


 
Posted : 08 Aug 2016 20H05
Share:

Scroll to Top