Forum Discussion

wsurguy's avatar
wsurguy
Adept
10 years ago

Permission denied when making a 'Reply' via the REST API.

Hi All,

  I am receiving a 'Permission Denied' when trying to make a reply to a message via the REST API.

My user is and 'Administrator' and has the 'Grant' permission 'Make REST API calls with modify access'.

I have read the post 'http://community.lithium.com/t5/Developers-Knowledge-Base/Replying-to-a-post-via-REST-API/ta-p/8569' and

my user has these permissions.

The user is able to make a reply in the GUI via the web with no issues.

It is just via the REST API that this occurrs.

 

I am migrating content into Lithium from another source and am using a C# application to perform the posts.

I am looping through the content to be migrated and uploading the parent message and child messages (replies).

The parent message uploads just fine.  I am able to retrieve the Lithium ID of the parent message for use in the reply

REST API.

 

Here are the headers for the request and the response.

 

REQUEST HEADER.

 

POST http://OURCOMMUNITY/restapi/vc/messages/id/6208/reply?restapi.session_key=VALIDSESSIONKEY HTTP/1.1
Accept: multipart/form-data
Content-Type: application/x-www-form-urlencoded
Host: OURCOMMUNITY
Content-Length: 89
Expect: 100-continue

message.author=%2Fusers%2Fid%2F180&label.labels=Wifi&message.body=This+a+simple+text+test

 

RESPONSE HEADER.

HTTP/1.1 200 OK
Date: Mon, 22 Jun 2015 22:22:04 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, private
Vary: Accept-Encoding
Connection: close
Content-Type: text/xml;charset=UTF-8
Content-Length: 179

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
   <response status="error">
   <error code="303">
     <message>
        Permission Denied
     </message>
  </error>
</response>

 

Are there some additional steps involved in the posting of a reply va the REST API?

 

 

  • Good to hear you managed to get the post returned wsurguy.

    You won't be able to specify the author of the post unless the user making the post has the "switch to other users" permission enabled.

     

    And even then you can't switch to a user that has any permission higher than your own.

    Labels on the other hand apply to a topic only. Not an individual post, you wouldn't pass those in with a reply.

    You could need to use tags if there's metadata you want to attach to the post.

     

    Sounds like you've got the right permissions working now, but just need a few tweaks to what you're handing to the API :)

  • Hi Tim,
    Thanks for the reply.
    When I tried the test you suggested I get 'An invalid set of parameters has been specified in the url.'.
    This is the URL that does not work - http://OURCOMMUNITY/t5/Wireless-Knowledge-Base/What-are-the-default-settings-for-WF121/td-p/#6209
    If I take off the '#' from the 6209 and try the URL http:// OURCOMMUNITY/t5/Wireless-Knowledge-Base/What-are-the-default-settings-for-WF121/ta-p/6209 the entry is displayed properly.
    Here is how I am getting the ID of the parent entry.
    In the response I receive from the post of the parent message I get the Lithium ID 6209 for the entry.
    It is found in the xml tag '6209' in the response and in the thread tag ''
    I then use that ID to try and make the post using the REST API as below.
    http://OURCOMMUNITY/restapi/vc/messages/id/6209/reply?restapi.session_key=VALIDSESSIONKEY
    Is there a different ID I should be using to make the reply?
    I tried this REST API call with the entry ID of 6209 and get the proper response.
    http://OURCOMMUNITY/restapi/vc/messages/id/6209/thread

    Wayne

    • Tim_h's avatar
      Tim_h
      Boss

      Apologies for the confusion wsurguy, I only include the # to indicate the number went there, it wasn't intended to be a part of the URL.

      You've figured that part out, we can move on :)

       

      You've got a valid ID, so I think the rest call is the incorrect one.

      Unless I'm wildly mistaken and I could well be...

       

      Switch out "reply" for "post" in your rest call. That might work better?

       

      http://community.lithium.com/t5/Community-API/bd-p/developers-rest-api?leaf-id=MessageDiscussion.messages.post#MessageDiscussion.messages.post

       

       

       

      • wsurguy's avatar
        wsurguy
        Adept

        Hi Tim,

          I gave it a try with the URL below.

         

        http://OURCOMMUNITY/restapi/vc/messages/id/6208/post?restapi.session_key=VALIDSESSIONKEY&message.author=%2Fusers%2Fid%2F180&label.labels=Wifi&message.body=TEST

         

        It returns the following.

         

        <?xml version="1.0" encoding="utf-8" standalone="yes"?>
        <response status="error">
        <error code="501">
        <message>
        Unknown path element at node &apos;message&apos;.
        </message>
        </error>
        </response>

         

        According to the API documentation message.author, label.labels and message.body should be valid.

        I tried encoding the '.' as '%2E'  in these parameters with the same result.

         

        Is there a more efficient way to troubleshoot these kind of issues?

        I am using fiddler and everthing looks ok but I am apparently missing something.

         

        Thanks

        Wayne