Not Able to Use user_id to Override Note Posting User using JSON Content Body

  • 22 December 2015
  • 2 replies
  • 43 views

Hey All,


I have been running into an issue where I am using an API key to CRUD users and tickets. When I try to add a note I am able to insert it onto a ticket, but I am not able to override the 'user_id' parameter to allow me to post as another user.


I am using the following code for the response:


//verifyFreshdeskUser returns a GET /contacts.json?query='email is <email>'&state='all'

$response = json_decode(json_encode(verifyFreshdeskUser(<email>)), true);

$id = $response[0]['user']['id'];

$note = array(

 "helpdesk_note" => array(

  "user_id" => $id,

  "body" => "It works!"

 )

);


The result is the user associated with the API key is associated with the note by default. I have also attempted to use a username/password combination instead of the API key, but get an 'Access Denied' response.


I would expect this to also work as based on the response from this post:
https://support.freshdesk.com/support/discussions/topics/2259


Any advice or suggestions as to how to troubleshoot this issue or would this be a bug?


Thanks,

Peter



This topic has been closed for comments

2 replies

Hi,


By default if user_id is an invalid value( example: null), the id of the user who is invoking the API would be taken into consideration while creating the note.


Please try to replace the $id with some hard-coded value of a user's id. If that works, then please re-check your $id initialisation part.


Also in verifyFreshdeskUser  the queryStrings should not include quotes. The corrected query string is ?query=email is <email>&state=all


If you still face problems in creating the note please share the X-Request-Id from the response headers.


Hope this helps. 


Thanks,

Ganesh


 


Hey Ganesh,


Thanks for the prompt response! I verified that the number I was getting back was a valid integer number which was being applied. (I accidentally added in the quotes when making this initial post, but they were not in the code.) I tested out the id associated with the User in both a hard coded and passed variable method, but received the same issue. This is the request IDs for the response from the hard coded values:

Hardcoded User ID: X-Request-Id: da8d5164e9605ec7e5361082ad4d3335


Thanks,

Peter