ACCESS_DENIED when using the sample code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • m3lis6
    Junior Member
    • Jul 2015
    • 2

    #1

    ACCESS_DENIED when using the sample code

    Hello,

    I'm trying to run the C# samples provided in the documentation to try out the API. My program works as expected up until the point it tries to place an order, and placeOrders returns an ACCESS_DENIED exception instead of the expected INVALID_BET_SIZE.

    Here is my code (mostly copied from the github samples)

    Code:
    var marketFilter = new MarketFilter();
    
    var eventTypes = jsonClient.listEventTypes(marketFilter);
    // forming a eventype id set for the eventype id extracted from the result
    ISet<string> eventypeIds = new HashSet<string>();
    foreach (EventTypeResult eventType in eventTypes)
    {
        if (eventType.EventType.Name.Equals("Horse Racing"))
        {
            Console.WriteLine("\nFound event type for Horse Racing: " + JsonConvert.Serialize<EventTypeResult>(eventType));
            //extracting eventype id
            eventypeIds.Add(eventType.EventType.Id);
        }
    }
    
    //ListMarketCatalogue: Get next available horse races, parameters:
    var time = new TimeRange();
    time.From = DateTime.Now;
    time.To = DateTime.Now.AddDays(1);
    
    marketFilter = new MarketFilter();
    marketFilter.EventTypeIds = eventypeIds;
    marketFilter.MarketStartTime = time;
    marketFilter.MarketCountries = new HashSet<string>() { "GB" };
    marketFilter.MarketTypeCodes = new HashSet<String>() { "WIN" };
    
    var marketSort = MarketSort.FIRST_TO_START;
    var maxResults = "1";
    
    //as an example we requested runner metadata 
    ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
    marketProjections.Add(MarketProjection.RUNNER_METADATA);
    
    
    Console.WriteLine("\nGetting the next available horse racing market");
    var marketCatalogues = jsonClient.listMarketCatalogue(marketFilter, marketProjections, marketSort, maxResults);
    //extract the marketId of the next horse race
    String marketId = marketCatalogues[0].MarketId;
    
    IList<string> marketIds = new List<string>();
    marketIds.Add(marketId);
    
    ISet<PriceData> priceData = new HashSet<PriceData>();
    //get all prices from the exchange
    priceData.Add(PriceData.EX_BEST_OFFERS);
    
    var priceProjection = new PriceProjection();
    priceProjection.PriceData = priceData;
    
    Console.WriteLine("\nGetting prices for market: " + marketId);
    var marketBook = jsonClient.listMarketBook(marketIds, priceProjection);
    
    if (marketBook.Count != 0)
    {
        //get the first runner from the market
        var runner = marketBook[0].Runners[0];
        Console.WriteLine("\nUsing Runner: " + JsonConvert.Serialize<Runner>(runner));
        var selectionId = runner.SelectionId;
        Console.WriteLine("\nPreparing to place bet on runner with Selection Id: " + selectionId
            + "\nBelonging to marketId: " + marketId
            + "\nBelow minimum betsize and expecting a INVALID_BET_SIZE response");
    
        IList<PlaceInstruction> placeInstructions = new List<PlaceInstruction>();
        var placeInstruction = new PlaceInstruction();
    
        placeInstruction.Handicap = 0;
        placeInstruction.Side = Side.BACK;
        placeInstruction.OrderType = OrderType.LIMIT;
    
        var limitOrder = new LimitOrder();
        limitOrder.PersistenceType = PersistenceType.LAPSE;
        // place a back bet at rediculous odds so it doesn't get matched 
        limitOrder.Price = 1000;
        limitOrder.Size = 0.1; // placing a bet below minimum stake, expecting a error in report
    
        placeInstruction.LimitOrder = limitOrder;
        placeInstruction.SelectionId = selectionId;
        placeInstructions.Add(placeInstruction);
    
        var customerRef = "123456";
        [COLOR="Red"][B]var placeExecutionReport = jsonClient.placeOrders(marketId, customerRef, placeInstructions); // Fails here with an ACCESS_DENIED response[/B][/COLOR]
    
        ExecutionReportErrorCode executionErrorcode = placeExecutionReport.ErrorCode;
        InstructionReportErrorCode instructionErroCode = placeExecutionReport.InstructionReports[0].ErrorCode;
        Console.WriteLine("\nPlaceExecutionReport error code is: " + executionErrorcode
            + "\nInstructionReport error code is: " + instructionErroCode);
    
        Console.WriteLine("\nDONE!");
    
        if (executionErrorcode != ExecutionReportErrorCode.BET_ACTION_ERROR && instructionErroCode != InstructionReportErrorCode.INVALID_BET_SIZE)
            Console.ReadLine();
    }
    else
    {
        Console.Write("\nSorry the market has no runner to place a bet on, try again later");
    }
    Any help appreciated.

    Thank you
    Last edited by m3lis6; 12-07-2015, 04:25 PM.
  • Lopiner
    Junior Member
    • Feb 2009
    • 117

    #2
    Hi,

    It's written in the code you posted in the following line:

    Code:
    limitOrder.Size = 0.1; // placing a bet below minimum stake, [B]expecting a error in report[/B]
    Order Size (Bet Size) must be 2€ minimum (there are other values for other currencies). It's written somewhere in the documentation but im not finding it.
    fooledbyabet.com

    Comment

    • m3lis6
      Junior Member
      • Jul 2015
      • 2

      #3
      Thank you for your reply. I am aware of the minimum bet size, however I was getting a different error than the expected error.

      In any case, I have managed to solve the problem, which was that I was using the delayed app key instead of the normal one

      Comment

      Working...
      X