Getting result data for a submission
To retrieve the remote file match you will need to get the location and source fields from part [9. Detailed Results] if it is a web match you will be able to retrieve the location and source when you call /check/results you will then use those two fields to search for the file content in the database.
When sending the request, we will need to send the following:
location - Location field from the submission
source - Source field from the submission
curl -X POST \
'https://codequiry.com/api/v1/check/getRemoteFile?location=cits3001_2021/RandomAgent.java&source=https://github.com/weesechedge/CITS3001-Project/blob/0c90fbe3112fe913727a8c04126fd6351bb8456c/cits3001_2021/RandomAgent.java' \
-H 'apikey: YOUR_API_KEY_HERE '
Sample Response (JSON Array)
{
"file": {
"id": 754614,
"filedir": "gh/871f4b3c4adbbf7fda07f01ef41c4065a1f4c8c5.java",
"content": "\npackage cits3001_2021;\n\nimport java.util.*;\n\n/**\n * A Java class for an agent to play in Resistance.\n * @author Tim French\n * **/\n\n\npublic class RandomAgent implements Agent{\n\n private String name;\n private Random random;\n private static int agentCount;\n private int players;//number of players\n\n\n /**\n *Creates a random agent with the given name\n *@param name, the name given to the agent and used on the scoreboard.\n **/\n public RandomAgent(String name){\n random = new Random();\n this.name = name;\n }\n\n /**\n * returns an instance of this agent for testing.\n * The progam should allocate the agent's name, \n * and can use a counter to ensure no two agents have the same name.\n * @return an instance of the agent.\n * **/\n public static Agent init(){\n switch(agentCount++){\n case 0: return new RandomAgent(\"Rando-the-1st\");\n case 1: return new RandomAgent(\"Rando-the 2nd\");\n case 2: return new RandomAgent(\"Rando-the-3rd\");\n default: return new RandomAgent(\"Rando-the-\"+agentCount+\"th\");\n }\n }\n\n /**\n * gets the name of the agent\n * @return the agent's name.\n * **/\n public String getName(){return name;}\n\n /**\n * Initialises a new game. \n * The agent should drop their current gameState and reinitialise all their game variables.\n * @param numPlayers the number of players in the game.\n * @param playerIndex the players index in the game.\n * @param spies, the index of all the spies in the game, if this agent is a spy (i.e. playerIndex is an element of spies)\n * **/\n public void newGame(int numPlayers, int playerIndex, int[] spies){\n players = numPlayers;\n }\n \n /**\n * This method is called when the agent is required to lead (propose) a mission\n * @param teamSize the number of agents to go on the mission\n * @param failsRequired the number of agent fails required for the mission to fail\n * @return an array of player indexes, the proposed mission.\n * **/\n public int[] proposeMission(int teamSize, int failsRequired){\n int[] team = new int[teamSize];\n boolean[] in = new boolean[players];",
"language_id": 1,
"filename": "RandomAgent.java",
"location": "cits3001_2021/RandomAgent.java",
"source": "https://github.com/weesechedge/CITS3001-Project/blob/0c90fbe3112fe913727a8c04126fd6351bb8456c/cits3001_2021/RandomAgent.java"
}
}
Error Format Response (422 error)
{
"error": "Could not find file or file has expired"
}
What's next
For optimal understanding of API usage, we recommend following this guide.
The API and documentation are constantly being updated during Beta. Please make sure to check the changelog regularly.