Logic App fails to get file content from GitHub

Lakshana 20 Reputation points
2025-02-12T02:20:38.8933333+00:00

Hi, I'm trying to work on an automatic KB update.. where when a file gets created or modified in GitHub, the logic app should be triggered, get the file content and save the data in azure AI Seacrh. But I've been facing with an issue which I'm not sure how to resolve.

I am using GitHub webhook to trigger the logic app, that works fine but when logic app tries to retrieve the file content using the GET request, it throws an Internal Server Error.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,389 questions
{count} votes

Accepted answer
  1. RithwikBojja 870 Reputation points Microsoft External Staff
    2025-02-13T09:50:28.1633333+00:00

    Hi @Lakshana,

    Firstly, created a custom Connector with webhook:

    enter image description here

    enter image description here

    Later, to get the file content, I have used Parse Json action to parse the trigger body.

    Then, used Compose to get modified file name. In my example, I have done it for modified files, you can also do for new files which are created by adding a parallel action.

    enter image description here

    I am getting the output as ["filename"] in Parse Json action , so modified it to filename using below function in Compose Action:

    for modified:

    replace(replace(replace(string(items('For_each')?['modified']), '[', ''), ']', ''), '"', '')
    

    for created :

    replace(replace(replace(string(items('For_each')?['created']), '[', ''), ']', ''), '"', '')
    

    Then, used the http action:

    enter image description here

    GET https://api.github.com/repos/{owner}/{repositoryname}/contents/{path/filenname.ext}
    

    You can also get Owner name, Repository Name and all from Parse JSON action only, but I have given it manually.

    My repository is public, so did not gave any authorization, if yours is private then need to give PAT token in authorization header while calling the file content.

    Output:

    enter image description here

    This is how I get the content of GITHUB files using Logic apps.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.