Error_in_order

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ghostbusters 2
    Junior Member
    • Apr 2015
    • 16

    #1

    Error_in_order

    Hello,
    I'm getting this error message when running from the web server, although I didn't get this a couple of weeks ago when running from a Linux terminal. Am not sure what the problem is! The full error message is:
    Status: FAILURE
    ErrorCode: PERMISSION_DENIED
    Instruction Status: FAILURE
    Instruction ErrorCode: ERROR_IN_ORDER

    The code I'm using to place the bet comes from the sample code and is:

    Code:
    function placeBet($appKey, $sessionToken, $marketId, $selectionId)
    {
    
        $params = '{"marketId":"' . $marketId . '",
                    "instructions":
                         [{"selectionId":"' . $selectionId . '",
                           "handicap":"0",
                           "side":"BACK",
                           "orderType":
                           "LIMIT",
                           "limitOrder":{"size":2,
                                        "price":2,
                                        "persistenceType":"LAPSE"}
                           }]
    		}';
    
        $jsonResponse = sportsApingRequest($appKey, $sessionToken, 'placeOrders', $params);
    
        return $jsonResponse[0]->result;
    
    }
    The error message comes from this code:
    Code:
    function printBetResult($betResult)
    {
        echo "Status: " . $betResult->status . "\n";
    
        if ($betResult->status == 'FAILURE') {
            echo "\nErrorCode: " . $betResult->errorCode;
            echo "\n\nInstruction Status: " . $betResult->instructionReports[0]->status;
            echo "\nInstruction ErrorCode: " . $betResult->instructionReports[0]->errorCode;
        } else
            echo "Bet placement succeeded!";
    }
    It seems to me that it's an error from the instruction parameters. I took the size and price out of " marks but that made no difference, and I can't see why it doesn't work.

    Any help would be much appreciated! (Tried google but only result was not having price/size in " marks.)
  • betdynamics
    Junior Member
    • Sep 2010
    • 534

    #2
    I think the PERMISSION_DENIED error is likely to be more pertinent.

    Are you using the correct AppKey? Make sure you are not using the delayed key.

    Comment

    • Ghostbusters 2
      Junior Member
      • Apr 2015
      • 16

      #3
      yes, i made that mistake and switched to the correct app key. i also updated the session key.
      [edit: as in i had already made that mistake, but it's still not working!]
      Last edited by Ghostbusters 2; 05-05-2015, 10:35 PM.

      Comment

      • Franklin1
        Junior Member
        • Mar 2012
        • 91

        #4
        do you really want:

        "handicap":"0"


        https://api.developer.betfair.com/se...aceInstruction

        handicap - double
        The handicap associated with the runner in case of Asian handicap markets, null otherwise.

        Comment

        • Ghostbusters 2
          Junior Member
          • Apr 2015
          • 16

          #5
          no i do not!
          I will change that and hopefully it will work.
          Don't know how it worked before with that in...
          Thanks also for that link, very useful.

          Comment

          • Ghostbusters 2
            Junior Member
            • Apr 2015
            • 16

            #6
            I removed the handicap part but it still returns that same error.

            If i change the price to 1, it returns the invalid bet size error, but when i set it back to 2, i get the error_in_order message.

            Comment

            • Fred77
              Junior Member
              • Jan 2009
              • 37

              #7
              A quick search of documentation reveals:

              PERMISSION_DENIED : Business rules do not allow order to be placed. You are either attempting to place the order using a Delayed Application Key or from a restricted jurisdiction (i.e. USA)

              You say you aren't using delayed app key so the issue is likely due to your move to a server that is in a restricted jurisdiction (or betfair's filter believes it is).

              Comment

              • Ghostbusters 2
                Junior Member
                • Apr 2015
                • 16

                #8
                thanks for the reply.
                very new to this so my abilities to search through the documentation are quite bad, but i've worked out that google isn't the best place to do it!
                contacting betfair so if i find out what's causing it will post a resolution...

                edit: just remembered my server does run on US time so it may be located in the US!

                Comment

                • Franklin1
                  Junior Member
                  • Mar 2012
                  • 91

                  #9
                  I actually think the betfair docs are pretty good, although there are pages I haven't noticed which have had important answers on.


                  put your server IP in here and see if it says US based
                  http://www.iplocation.net/

                  Comment

                  • Ghostbusters 2
                    Junior Member
                    • Apr 2015
                    • 16

                    #10
                    the docs are quite good, i just have trouble finding the right parts!

                    my server is definitely US based, so i've moved the files to a UK server. the only problem is now that the response from this query is null when i run it on the new server, but has results when running it on the old one!

                    Code:
                    function getAllUkHorseRacingMarket($appKey, $sessionToken)
                    {
                    
                        $params = '{"filter":{"eventTypeIds":["7"],
                    			  "marketCountries":["GB"],
                                  "marketTypeCodes":["WIN"],
                                  "marketStartTime":{"from":"' . date('c') . '"}},
                                  "sort":"FIRST_TO_START",
                                  "maxResults":"1000",
                                  "marketProjection": [
                                    "RUNNER_DESCRIPTION"
                    		]}';
                    
                        $jsonResponse = sportsApingRequest($appKey, $sessionToken, 'listMarketCatalogue', $params);
                        print_r($jsonResponse);
                        return $jsonResponse[0]->result;
                    }
                    am currently going through the docs to see if there's something i've forgotten that i did server side which it needs to run...

                    Comment

                    • Franklin1
                      Junior Member
                      • Mar 2012
                      • 91

                      #11
                      something to do with times? Do your servers both run on the same time zone?

                      Otherwise date/time formatting? (locale?)

                      if you can post up your actual JSON POST data it might be clear.

                      Comment

                      • Ghostbusters 2
                        Junior Member
                        • Apr 2015
                        • 16

                        #12
                        Hello,
                        yes, the start times are different!
                        [thanks for the help i'm new to php and api's! i hope what i post below is the JSON POST data?]

                        the new server returns this
                        Code:
                        1. Get horse racing market of all races.... Post Data: [{ "jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketCatalogue", "params" :{"filter":{
                        "eventTypeIds":["7"], "marketCountries":["GB"], "marketTypeCodes":["WIN"], "marketStartTime":{
                        "from":"2015-05-06T18:05:08+01:00"}},
                        "sort":"FIRST_TO_START", "maxResults":"1000", "marketProjection": [ "RUNNER_DESCRIPTION" ]}, "id": 1}] Response: null
                        the old one returns a time of "2015-05-06T11:20:53-06:00"

                        I think this in the parameters:
                        Code:
                        "marketStartTime":{"from":"' . date('c') . '"}},
                        returns current date&time
                        so i'm trying to subtract a few hours from this to see if it gives some results. i would think it returns results from this time, but then there are still some races today so there should be something returned even running it now?

                        Comment

                        • Ghostbusters 2
                          Junior Member
                          • Apr 2015
                          • 16

                          #13
                          i took away 10 hours, but it still returns null...

                          Comment

                          • Franklin1
                            Junior Member
                            • Mar 2012
                            • 91

                            #14
                            The request looks ok to me..

                            there are exceptions returned by Betfair return in the HTTP response which can give info when there is no JSON data returned.

                            It's probably already being handled(ignored) in your sportsApingRequest function.

                            https://api.developer.betfair.com/se...ing+Exceptions
                            https://api.developer.betfair.com/se...nts+Exceptions

                            I can't help you get it in php, but I do something like this in vb.net:
                            try
                            'this is where I handle the http
                            Catch e As System.Net.WebException
                            'catch an error handling it
                            print("WebException Request Error: " & e.Message)
                            If e.Response IsNot Nothing Then
                            reader = New StreamReader(e.Response.GetResponseStream())
                            body = reader.ReadToEnd()
                            print("Body: " & body)
                            end if
                            end try

                            Comment

                            • Franklin1
                              Junior Member
                              • Mar 2012
                              • 91

                              #15
                              Another thing you might want to try is changing marketStartTime to GMT (ie removing the +01:00 part on the right). I haven't checked this though.

                              Comment

                              Working...
                              X