Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
long selectionId = 0;
            if ( marketBookReturn.size() != 0 ) {
                Runner runner = marketBookReturn.get(0).getRunners().get(0);
                selectionId = runner.getSelectionId();
                System.out.println("7. Place a bet below minimum stake to prevent the bet actually " +
                        "being placed for marketId: "+marketIdChosen+" with selectionId: "+selectionId+"...\n\n");
                List<PlaceInstruction> instructions = new ArrayList<PlaceInstruction>();
                PlaceInstruction instruction = new PlaceInstruction();
                instruction.setHandicap(0);
                instruction.setSide(Side.BACK);
                instruction.setOrderType(OrderType.LIMIT);

                LimitOrder limitOrder = new LimitOrder();
                limitOrder.setPersistenceType(PersistenceType.LAPSE);
                //API-NG will return an error with the default size=0.01. This is an expected behaviour.
                //You can adjust the size and price value in the "apingdemo.properties" file
                limitOrder.setPrice(getPrice());
                limitOrder.setSize(getSize());

                instruction.setLimitOrder(limitOrder);
                instruction.setSelectionId(selectionId);
                instructions.add(instruction);

                String customerRef = "1";

                PlaceExecutionReport placeBetResult = jsonOperations.placeOrders(marketIdChosen, instructions, customerRef, applicationKey, sessionToken);

                // Handling the operation result
                if (placeBetResult.getStatus() == ExecutionReportStatus.SUCCESS) {
                    System.out.println("Your bet has been placed!!");
                    System.out.println(placeBetResult.getInstructionReports());
                } else if (placeBetResult.getStatus() == ExecutionReportStatus.FAILURE) {
                    System.out.println("Your bet has NOT been placed :*( ");
                    System.out.println("The error is: " + placeBetResult.getErrorCode() + ": " + placeBetResult.getErrorCode().getMessage());
                    System.out.println("Sorry, more luck next time\n\n");
                }
            } else {
                System.out.println("Sorry, no runners found\n\n");
            }

 

Error Handling - non HTTP 200 responses
Anchor
Handling
Handling

 

 

 

The below guidance is for customers who are looking to handle additional HTTP responses other than the HTTP 200 success code when using Rescript requests.

 

1.    In RescriptResponseHandler we need to modify the handleResponse method so that an HttpResponseException is thrown for unsuccessful response 

...

Code Block
languagejava
public class ResponseError {


    private Detail detail;

    private String  faultcode;

    private String  faultstring;

    public String getFaultstring() {


        return faultstring;


    }


    public void setFaultstring(String faultstring)
{


        this.faultstring =
faultstring;


    }

    public String getFaultcode() {


        return faultcode;

    }

    public void setFaultcode(String faultcode) {


        this.faultcode =
faultcode;


    }


    public Detail getDetail() {

        return detail;


    }

    public void setDetail(Detail detail) {

        this.detail = detail;

    }


}


public class Detail {


    private APINGException APINGException;

    public APINGException getAPINGException() {

        return APINGException;

    }

    public void setAPINGException(APINGException
aPINGException) {


        APINGException =
aPINGException;

    }

 

Anchor
 
Handling
Handling