JSON request errors Mollybet API












0















We are experiencing problems in section 4.3.1 Create a new bet placement order with API https://api.mollybet.com/docs/v1/#create-a-new-bet-placement-order.



The client used is c# Httpclient, and we are sending the parameters as JSON body.



{
"betslip_id":"aff87f1773774ef7b04e81992c038e8f",
"price":"2.06",
"stake":"["EUR", 13]",
"duration":"15",
"accounts":"["ibc", "_99899bb2_"]",
"adaptive_bookies":"[ibc]",
"ignore_system_maintenance":false,
"no_put_offer_exchange":false,
"bookie_min_stakes":"{}",
"user_data":null
}


validation_errors



Please refer to screenshots:





We are unable to get past this step, any advice would be much appreciated.



EDIT - CODE THAT GENERATES JSON AS REQUESTED BY dbc :



    private void doPlace(string betSlipId,double price , double stake , string bookie, string accountName)
{
try
{
//string placebetLink = "https://pro.sportmarket.com/trade/place_order";
//var postData = new FormUrlEncodedContent(new
//{
// new KeyValuePair<string,string>("betslip_id",betSlipId),
// new KeyValuePair<string,string>("price" , price.ToString()),
// new KeyValuePair<string, string>("request_uuid",getRandom()),
// new KeyValuePair<string, string>("timeout","20"),
// new KeyValuePair<string,string>("stake",stake.ToString()),
// new KeyValuePair<string,string>("accounts",accountName),
// new KeyValuePair<string,string>("adaptive",bookie),
// new KeyValuePair<string, string>("ignore_autoplacing","false"),
// new KeyValuePair<string, string>("csrfmiddlewaretoken", csrToken)
//});

//HttpResponseMessage placeResponse = httpClient.PostAsync(placebetLink, postData).Result;
//placeResponse.EnsureSuccessStatusCode();

//string content = placeResponse.Content.ReadAsStringAsync().Result;
//ApiClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Requested-With", "XMLHttpRequest");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
string stakeStr = string.Format("["EUR", {0}]", stake);
string placebetUrl = string.Format("{0}v1/orders/", endPonit);
//var postData = new FormUrlEncodedContent(new
//{
// new KeyValuePair<string,string>("betslip_id",betSlipId),
// new KeyValuePair<string,string>("price" , price.ToString()),
// new KeyValuePair<string,string>("stake",stakeStr),
// new KeyValuePair<string,string>("duration","15"),
// new KeyValuePair<string,string>("accounts",accountName),
// new KeyValuePair<string,string>("adaptive_bookies",string.Format("[{0}]",bookie)),
// new KeyValuePair<string, string>("ignore_system_maintenance","false"),
// new KeyValuePair<string, string>("no_put_offer_exchange","false"),
// new KeyValuePair<string, string>("bookie_min_stakes","{}"),
// new KeyValuePair<string, string>("user_data","")

//});

PlaceRequest requestJson = new PlaceRequest();
requestJson.betslip_id = betSlipId;
requestJson.price = price.ToString();
requestJson.stake = stakeStr;
requestJson.accounts = accountName;
requestJson.duration = "15";
requestJson.adaptive_bookies = string.Format("[{0}]", bookie);
requestJson.ignore_system_maintenance = false;
requestJson.no_put_offer_exchange = false;
requestJson.bookie_min_stakes = "{}";

string jsonStr = JsonConvert.SerializeObject(requestJson);

HttpResponseMessage placeResponse = ApiClient.PostAsync(placebetUrl, new StringContent(jsonStr, Encoding.UTF8, "application/json")).Result;
placeResponse.EnsureSuccessStatusCode();

string content = placeResponse.Content.ReadAsStringAsync().Result;
}
catch (Exception e)
{

}

}









share|improve this question

























  • user_data [ string ] (optional) is one issue. You're passing it null which is not a string, try passing "user_data":"" instead.

    – Wayne Phipps
    Jan 2 at 13:38













  • I think you just need to look at the API doc in more detail. For example, the JSON value ["EUR", 100] represents the amount of one hundred euros. You have backslashes and quotes in your string "stake":"["EUR", 13]" which it appears to be complaining about

    – Wayne Phipps
    Jan 2 at 13:46











  • if you upload your images via the stack overflow imgur we can embed the images into your question

    – WhatsThePoint
    Jan 2 at 14:12











  • "["EUR", 13]" and "["ibc", "_99899bb2_"]" are double-serialized -- i.e. they were arrays that were serialized to JSON strings, then those strings embedded in some larger object when was then serialized, causing the arrays to get serialized twice. Is this what you meant to do? Can you please share the code that generates this JSON, i.e. a Minimal, Complete, and Verifiable example?

    – dbc
    Jan 2 at 23:42











  • @dbc We are still experiencing the same issue, I have provided the code that generates the json.

    – Banjo
    Jan 22 at 8:11
















0















We are experiencing problems in section 4.3.1 Create a new bet placement order with API https://api.mollybet.com/docs/v1/#create-a-new-bet-placement-order.



The client used is c# Httpclient, and we are sending the parameters as JSON body.



{
"betslip_id":"aff87f1773774ef7b04e81992c038e8f",
"price":"2.06",
"stake":"["EUR", 13]",
"duration":"15",
"accounts":"["ibc", "_99899bb2_"]",
"adaptive_bookies":"[ibc]",
"ignore_system_maintenance":false,
"no_put_offer_exchange":false,
"bookie_min_stakes":"{}",
"user_data":null
}


validation_errors



Please refer to screenshots:





We are unable to get past this step, any advice would be much appreciated.



EDIT - CODE THAT GENERATES JSON AS REQUESTED BY dbc :



    private void doPlace(string betSlipId,double price , double stake , string bookie, string accountName)
{
try
{
//string placebetLink = "https://pro.sportmarket.com/trade/place_order";
//var postData = new FormUrlEncodedContent(new
//{
// new KeyValuePair<string,string>("betslip_id",betSlipId),
// new KeyValuePair<string,string>("price" , price.ToString()),
// new KeyValuePair<string, string>("request_uuid",getRandom()),
// new KeyValuePair<string, string>("timeout","20"),
// new KeyValuePair<string,string>("stake",stake.ToString()),
// new KeyValuePair<string,string>("accounts",accountName),
// new KeyValuePair<string,string>("adaptive",bookie),
// new KeyValuePair<string, string>("ignore_autoplacing","false"),
// new KeyValuePair<string, string>("csrfmiddlewaretoken", csrToken)
//});

//HttpResponseMessage placeResponse = httpClient.PostAsync(placebetLink, postData).Result;
//placeResponse.EnsureSuccessStatusCode();

//string content = placeResponse.Content.ReadAsStringAsync().Result;
//ApiClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Requested-With", "XMLHttpRequest");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
string stakeStr = string.Format("["EUR", {0}]", stake);
string placebetUrl = string.Format("{0}v1/orders/", endPonit);
//var postData = new FormUrlEncodedContent(new
//{
// new KeyValuePair<string,string>("betslip_id",betSlipId),
// new KeyValuePair<string,string>("price" , price.ToString()),
// new KeyValuePair<string,string>("stake",stakeStr),
// new KeyValuePair<string,string>("duration","15"),
// new KeyValuePair<string,string>("accounts",accountName),
// new KeyValuePair<string,string>("adaptive_bookies",string.Format("[{0}]",bookie)),
// new KeyValuePair<string, string>("ignore_system_maintenance","false"),
// new KeyValuePair<string, string>("no_put_offer_exchange","false"),
// new KeyValuePair<string, string>("bookie_min_stakes","{}"),
// new KeyValuePair<string, string>("user_data","")

//});

PlaceRequest requestJson = new PlaceRequest();
requestJson.betslip_id = betSlipId;
requestJson.price = price.ToString();
requestJson.stake = stakeStr;
requestJson.accounts = accountName;
requestJson.duration = "15";
requestJson.adaptive_bookies = string.Format("[{0}]", bookie);
requestJson.ignore_system_maintenance = false;
requestJson.no_put_offer_exchange = false;
requestJson.bookie_min_stakes = "{}";

string jsonStr = JsonConvert.SerializeObject(requestJson);

HttpResponseMessage placeResponse = ApiClient.PostAsync(placebetUrl, new StringContent(jsonStr, Encoding.UTF8, "application/json")).Result;
placeResponse.EnsureSuccessStatusCode();

string content = placeResponse.Content.ReadAsStringAsync().Result;
}
catch (Exception e)
{

}

}









share|improve this question

























  • user_data [ string ] (optional) is one issue. You're passing it null which is not a string, try passing "user_data":"" instead.

    – Wayne Phipps
    Jan 2 at 13:38













  • I think you just need to look at the API doc in more detail. For example, the JSON value ["EUR", 100] represents the amount of one hundred euros. You have backslashes and quotes in your string "stake":"["EUR", 13]" which it appears to be complaining about

    – Wayne Phipps
    Jan 2 at 13:46











  • if you upload your images via the stack overflow imgur we can embed the images into your question

    – WhatsThePoint
    Jan 2 at 14:12











  • "["EUR", 13]" and "["ibc", "_99899bb2_"]" are double-serialized -- i.e. they were arrays that were serialized to JSON strings, then those strings embedded in some larger object when was then serialized, causing the arrays to get serialized twice. Is this what you meant to do? Can you please share the code that generates this JSON, i.e. a Minimal, Complete, and Verifiable example?

    – dbc
    Jan 2 at 23:42











  • @dbc We are still experiencing the same issue, I have provided the code that generates the json.

    – Banjo
    Jan 22 at 8:11














0












0








0


1






We are experiencing problems in section 4.3.1 Create a new bet placement order with API https://api.mollybet.com/docs/v1/#create-a-new-bet-placement-order.



The client used is c# Httpclient, and we are sending the parameters as JSON body.



{
"betslip_id":"aff87f1773774ef7b04e81992c038e8f",
"price":"2.06",
"stake":"["EUR", 13]",
"duration":"15",
"accounts":"["ibc", "_99899bb2_"]",
"adaptive_bookies":"[ibc]",
"ignore_system_maintenance":false,
"no_put_offer_exchange":false,
"bookie_min_stakes":"{}",
"user_data":null
}


validation_errors



Please refer to screenshots:





We are unable to get past this step, any advice would be much appreciated.



EDIT - CODE THAT GENERATES JSON AS REQUESTED BY dbc :



    private void doPlace(string betSlipId,double price , double stake , string bookie, string accountName)
{
try
{
//string placebetLink = "https://pro.sportmarket.com/trade/place_order";
//var postData = new FormUrlEncodedContent(new
//{
// new KeyValuePair<string,string>("betslip_id",betSlipId),
// new KeyValuePair<string,string>("price" , price.ToString()),
// new KeyValuePair<string, string>("request_uuid",getRandom()),
// new KeyValuePair<string, string>("timeout","20"),
// new KeyValuePair<string,string>("stake",stake.ToString()),
// new KeyValuePair<string,string>("accounts",accountName),
// new KeyValuePair<string,string>("adaptive",bookie),
// new KeyValuePair<string, string>("ignore_autoplacing","false"),
// new KeyValuePair<string, string>("csrfmiddlewaretoken", csrToken)
//});

//HttpResponseMessage placeResponse = httpClient.PostAsync(placebetLink, postData).Result;
//placeResponse.EnsureSuccessStatusCode();

//string content = placeResponse.Content.ReadAsStringAsync().Result;
//ApiClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Requested-With", "XMLHttpRequest");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
string stakeStr = string.Format("["EUR", {0}]", stake);
string placebetUrl = string.Format("{0}v1/orders/", endPonit);
//var postData = new FormUrlEncodedContent(new
//{
// new KeyValuePair<string,string>("betslip_id",betSlipId),
// new KeyValuePair<string,string>("price" , price.ToString()),
// new KeyValuePair<string,string>("stake",stakeStr),
// new KeyValuePair<string,string>("duration","15"),
// new KeyValuePair<string,string>("accounts",accountName),
// new KeyValuePair<string,string>("adaptive_bookies",string.Format("[{0}]",bookie)),
// new KeyValuePair<string, string>("ignore_system_maintenance","false"),
// new KeyValuePair<string, string>("no_put_offer_exchange","false"),
// new KeyValuePair<string, string>("bookie_min_stakes","{}"),
// new KeyValuePair<string, string>("user_data","")

//});

PlaceRequest requestJson = new PlaceRequest();
requestJson.betslip_id = betSlipId;
requestJson.price = price.ToString();
requestJson.stake = stakeStr;
requestJson.accounts = accountName;
requestJson.duration = "15";
requestJson.adaptive_bookies = string.Format("[{0}]", bookie);
requestJson.ignore_system_maintenance = false;
requestJson.no_put_offer_exchange = false;
requestJson.bookie_min_stakes = "{}";

string jsonStr = JsonConvert.SerializeObject(requestJson);

HttpResponseMessage placeResponse = ApiClient.PostAsync(placebetUrl, new StringContent(jsonStr, Encoding.UTF8, "application/json")).Result;
placeResponse.EnsureSuccessStatusCode();

string content = placeResponse.Content.ReadAsStringAsync().Result;
}
catch (Exception e)
{

}

}









share|improve this question
















We are experiencing problems in section 4.3.1 Create a new bet placement order with API https://api.mollybet.com/docs/v1/#create-a-new-bet-placement-order.



The client used is c# Httpclient, and we are sending the parameters as JSON body.



{
"betslip_id":"aff87f1773774ef7b04e81992c038e8f",
"price":"2.06",
"stake":"["EUR", 13]",
"duration":"15",
"accounts":"["ibc", "_99899bb2_"]",
"adaptive_bookies":"[ibc]",
"ignore_system_maintenance":false,
"no_put_offer_exchange":false,
"bookie_min_stakes":"{}",
"user_data":null
}


validation_errors



Please refer to screenshots:





We are unable to get past this step, any advice would be much appreciated.



EDIT - CODE THAT GENERATES JSON AS REQUESTED BY dbc :



    private void doPlace(string betSlipId,double price , double stake , string bookie, string accountName)
{
try
{
//string placebetLink = "https://pro.sportmarket.com/trade/place_order";
//var postData = new FormUrlEncodedContent(new
//{
// new KeyValuePair<string,string>("betslip_id",betSlipId),
// new KeyValuePair<string,string>("price" , price.ToString()),
// new KeyValuePair<string, string>("request_uuid",getRandom()),
// new KeyValuePair<string, string>("timeout","20"),
// new KeyValuePair<string,string>("stake",stake.ToString()),
// new KeyValuePair<string,string>("accounts",accountName),
// new KeyValuePair<string,string>("adaptive",bookie),
// new KeyValuePair<string, string>("ignore_autoplacing","false"),
// new KeyValuePair<string, string>("csrfmiddlewaretoken", csrToken)
//});

//HttpResponseMessage placeResponse = httpClient.PostAsync(placebetLink, postData).Result;
//placeResponse.EnsureSuccessStatusCode();

//string content = placeResponse.Content.ReadAsStringAsync().Result;
//ApiClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Requested-With", "XMLHttpRequest");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
string stakeStr = string.Format("["EUR", {0}]", stake);
string placebetUrl = string.Format("{0}v1/orders/", endPonit);
//var postData = new FormUrlEncodedContent(new
//{
// new KeyValuePair<string,string>("betslip_id",betSlipId),
// new KeyValuePair<string,string>("price" , price.ToString()),
// new KeyValuePair<string,string>("stake",stakeStr),
// new KeyValuePair<string,string>("duration","15"),
// new KeyValuePair<string,string>("accounts",accountName),
// new KeyValuePair<string,string>("adaptive_bookies",string.Format("[{0}]",bookie)),
// new KeyValuePair<string, string>("ignore_system_maintenance","false"),
// new KeyValuePair<string, string>("no_put_offer_exchange","false"),
// new KeyValuePair<string, string>("bookie_min_stakes","{}"),
// new KeyValuePair<string, string>("user_data","")

//});

PlaceRequest requestJson = new PlaceRequest();
requestJson.betslip_id = betSlipId;
requestJson.price = price.ToString();
requestJson.stake = stakeStr;
requestJson.accounts = accountName;
requestJson.duration = "15";
requestJson.adaptive_bookies = string.Format("[{0}]", bookie);
requestJson.ignore_system_maintenance = false;
requestJson.no_put_offer_exchange = false;
requestJson.bookie_min_stakes = "{}";

string jsonStr = JsonConvert.SerializeObject(requestJson);

HttpResponseMessage placeResponse = ApiClient.PostAsync(placebetUrl, new StringContent(jsonStr, Encoding.UTF8, "application/json")).Result;
placeResponse.EnsureSuccessStatusCode();

string content = placeResponse.Content.ReadAsStringAsync().Result;
}
catch (Exception e)
{

}

}






c# json rest unicode django-rest-framework






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 23 at 16:47







Banjo

















asked Jan 2 at 13:21









BanjoBanjo

11




11













  • user_data [ string ] (optional) is one issue. You're passing it null which is not a string, try passing "user_data":"" instead.

    – Wayne Phipps
    Jan 2 at 13:38













  • I think you just need to look at the API doc in more detail. For example, the JSON value ["EUR", 100] represents the amount of one hundred euros. You have backslashes and quotes in your string "stake":"["EUR", 13]" which it appears to be complaining about

    – Wayne Phipps
    Jan 2 at 13:46











  • if you upload your images via the stack overflow imgur we can embed the images into your question

    – WhatsThePoint
    Jan 2 at 14:12











  • "["EUR", 13]" and "["ibc", "_99899bb2_"]" are double-serialized -- i.e. they were arrays that were serialized to JSON strings, then those strings embedded in some larger object when was then serialized, causing the arrays to get serialized twice. Is this what you meant to do? Can you please share the code that generates this JSON, i.e. a Minimal, Complete, and Verifiable example?

    – dbc
    Jan 2 at 23:42











  • @dbc We are still experiencing the same issue, I have provided the code that generates the json.

    – Banjo
    Jan 22 at 8:11



















  • user_data [ string ] (optional) is one issue. You're passing it null which is not a string, try passing "user_data":"" instead.

    – Wayne Phipps
    Jan 2 at 13:38













  • I think you just need to look at the API doc in more detail. For example, the JSON value ["EUR", 100] represents the amount of one hundred euros. You have backslashes and quotes in your string "stake":"["EUR", 13]" which it appears to be complaining about

    – Wayne Phipps
    Jan 2 at 13:46











  • if you upload your images via the stack overflow imgur we can embed the images into your question

    – WhatsThePoint
    Jan 2 at 14:12











  • "["EUR", 13]" and "["ibc", "_99899bb2_"]" are double-serialized -- i.e. they were arrays that were serialized to JSON strings, then those strings embedded in some larger object when was then serialized, causing the arrays to get serialized twice. Is this what you meant to do? Can you please share the code that generates this JSON, i.e. a Minimal, Complete, and Verifiable example?

    – dbc
    Jan 2 at 23:42











  • @dbc We are still experiencing the same issue, I have provided the code that generates the json.

    – Banjo
    Jan 22 at 8:11

















user_data [ string ] (optional) is one issue. You're passing it null which is not a string, try passing "user_data":"" instead.

– Wayne Phipps
Jan 2 at 13:38







user_data [ string ] (optional) is one issue. You're passing it null which is not a string, try passing "user_data":"" instead.

– Wayne Phipps
Jan 2 at 13:38















I think you just need to look at the API doc in more detail. For example, the JSON value ["EUR", 100] represents the amount of one hundred euros. You have backslashes and quotes in your string "stake":"["EUR", 13]" which it appears to be complaining about

– Wayne Phipps
Jan 2 at 13:46





I think you just need to look at the API doc in more detail. For example, the JSON value ["EUR", 100] represents the amount of one hundred euros. You have backslashes and quotes in your string "stake":"["EUR", 13]" which it appears to be complaining about

– Wayne Phipps
Jan 2 at 13:46













if you upload your images via the stack overflow imgur we can embed the images into your question

– WhatsThePoint
Jan 2 at 14:12





if you upload your images via the stack overflow imgur we can embed the images into your question

– WhatsThePoint
Jan 2 at 14:12













"["EUR", 13]" and "["ibc", "_99899bb2_"]" are double-serialized -- i.e. they were arrays that were serialized to JSON strings, then those strings embedded in some larger object when was then serialized, causing the arrays to get serialized twice. Is this what you meant to do? Can you please share the code that generates this JSON, i.e. a Minimal, Complete, and Verifiable example?

– dbc
Jan 2 at 23:42





"["EUR", 13]" and "["ibc", "_99899bb2_"]" are double-serialized -- i.e. they were arrays that were serialized to JSON strings, then those strings embedded in some larger object when was then serialized, causing the arrays to get serialized twice. Is this what you meant to do? Can you please share the code that generates this JSON, i.e. a Minimal, Complete, and Verifiable example?

– dbc
Jan 2 at 23:42













@dbc We are still experiencing the same issue, I have provided the code that generates the json.

– Banjo
Jan 22 at 8:11





@dbc We are still experiencing the same issue, I have provided the code that generates the json.

– Banjo
Jan 22 at 8:11












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007150%2fjson-request-errors-mollybet-api%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007150%2fjson-request-errors-mollybet-api%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mossoró

Error while reading .h5 file using the rhdf5 package in R

Pushsharp Apns notification error: 'InvalidToken'