none
HTTP POST Office Graph API - The request body cannot be empty RRS feed

  • Question

  • Hi all,

    I am using an Azure Logic App to automatically create a tab within Microsoft Teams that points to a Microsoft Planner plan.

    On August 22 I had successfully created this workflow as a test. Since then I haven't changed the workflow.
    Now today I wanted to take this workflow in production, assuming all would still work fine as in August, but unfortunately it is throwing me an error:

    {
    "error": {
    "code": "InvalidRequest",
    "message": "The request body cannot be empty.\r\nParameter name: requestContent",
    "innerError": {
    "request-id": "1f3107ee-b743-4b4c-b988-a8bb400b53fb",
    "date": "2019-10-21T14:15:25"
    }
    }

    }

    Let me explain the 2-tier process.

    Step 1:

    First I request an access token.

    Method: POST
    URI: https://login.microsoftonline.com/<<Tenant ID>>/oauth2/v2.0/token
    Body: client_id=<<My client id>>&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=<<My secret code>>&grant_type=client_credentials
    Headers: "Content-Type": "application/x-www-form-urlencoded"

    I receive a response perfectly as expected:

    {
    "token_type": "Bearer",
    "expires_in": 3600,
    "ext_expires_in": 3600,
    "access_token": "ey<<Incredibly long code>>pOPA"
    }

    So this step still works well.

    Step 2:

    Telling the Office Graph API that I would like to create a new tab in Microsoft Teams.

    Method: POST
    URI: https://graph.microsoft.com/v1.0/teams/<<My Teams id>>/channels/19:<<My channel id>>@thread.skype/tabs
    Body:

    {
    "configuration": {
    "contentUrl": "https://tasks.office.com/<<tenant name>>.onmicrosoft.com/Home/PlannerFrame?page=7&planId=<<My Plan id>>",
    "entityID": "rdKJDncWDE6L5j98VcslQJYAEfPX",
    "removeUrl": "https://tasks.office.com/<<tenant name>>.onmicrosoft.com/Home/PlannerFrame?page=7&planId=<<My Plan id>>",
    "websiteUrl": "https://tasks.office.com/<<tenant name>>.onmicrosoft.com/Home/PlannerFrame?page=7&planId=<<My Plan id>>"
    },
    "displayName": "Takenlijst",
    "teamsAppId": "com.microsoft.teamspace.tab.planner"
    }

    Headers:

    {
    "Authorization": "*sanitized*", (Bearer <<Access token obtained in Step 1>>)
    "Content-Type": "application/x-www-form-urlencoded"
    }

    Office Graph API doesn't agree. Error code: BadRequest and throws the error mentioned above.

    Using this article I was trying to figure out what I have missed. https://docs.microsoft.com/en-us/graph/api/teamstab-add?view=graph-rest-beta
    Had the API been updated, did I do something wrong?

    Hoping someone could help me out!

    Thanks in advance for all help provided!

    Kind regards,

    Joost

    Monday, October 21, 2019 8:21 PM

Answers

  • I received feedback from a Microsoft Integration Support Eng.

    It appears that the API has been updated, and that I would need to change two properties of my HTTP POST request:

    HEADER

    FROM:

    "Content-Type": "application/x-www-form-urlencoded"

    TO:

    "Content-Type": "application/json"

    BODY

    Include: 

    "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/com.microsoft.teamspace.tab.planner",​

    Hope this helps other people. My issue is resolved.

    • Marked as answer by jvdlinden91 Wednesday, October 23, 2019 2:07 PM
    Wednesday, October 23, 2019 2:07 PM