Code:
if (Quest && oSession.uriContains("api/v1/archives/stories/update/active-node-v3")){
try{
//DECODING AND CONVERTING REQUEST AND RESPONSE
oSession.utilDecodeRequest();
oSession.utilDecodeResponse();
var jsonRequest = oSession.GetRequestBodyAsString();
var oJsonRequest = Fiddler.WebFormats.JSON.JsonDecode(jsonRequest);
var jsonResponse = oSession.GetResponseBodyAsString();
var oJsonResponse = Fiddler.WebFormats.JSON.JsonDecode(jsonResponse);
//GETTING VARIABLES FROM SELECTED CHALLENGE
if(oJsonResponse.JSONObject["activeNodesFull"].Count == 0) return;
var role = oJsonRequest.JSONObject["role"];
if(role == "both") role = "survivor";
var neededProgression = oJsonResponse.JSONObject["activeNodesFull"][0]["objectives"][0]["neededProgression"];
var questEvents = oJsonResponse.JSONObject["activeNodesFull"][0]["objectives"][0]["questEvent"];
var matchId = System.Guid.NewGuid().ToString();
var requestBody = '{"matchId":"'+matchId+'","questEvents":[';
for(var i=0;i<questEvents.Count;i++){
var repetition = questEvents[i]["repetition"];
repetition *= neededProgression;
var questEventId = questEvents[i]["questEventId"];
var parameters = questEvents[i]["parameters"];
if(parameters != undefined) requestBody += '{"parameters":"'+parameters+'","questEventId":"'+questEventId+'","repetition":'+repetition+'}';
else requestBody += '{"questEventId":"'+questEventId+'","repetition":'+repetition+'}';
if(questEvents.Count > 1 && i != questEvents.Count - 1) requestBody += ",";
}
requestBody += '],"role":"'+role+'"}';
//GENERATING REQUEST WITH VARIABLES TO COMPLETE THE CHALLENGE
var request = new System.Net.WebClient();
var currentUrl = new System.Uri(oSession.fullUrl);
var baseUrl = currentUrl.GetLeftPart(System.UriPartial.Authority );
var url = baseUrl+"/api/v1/archives/stories/update/quest-progress-v2";
request.Headers.Set("X-HTTP-Method-Override", "POST");
request.Headers.Add("Host", "brill.live.bhvrdbd.com");
request.Headers.Add("Accept", "*/*");
request.Headers.Add("Content-Type", "application/json");
request.Headers.Add("Cookie", oSession.oRequest["Cookie"]);
var responseBody = request.UploadString(url, "POST", requestBody);
}
catch(e){FiddlerObject.log("Error unlocking challenge");}
}