betdaq icon indicating copy to clipboard operation
betdaq copied to clipboard

Placing an order - Exception: Server was unable to read request

Open kauto23 opened this issue 7 years ago • 4 comments

Hi,

I'm attempting to create and place an order by running the following:

from betdaq.apiclient import APIClient
from betdaq import filters, enums

api = APIClient('*', '*')

myorder = [filters.create_order(82026914, 2.00, 2.40, enums.Polarity(1), 0, 0)]
api.betting.place_orders(myorder, receipt=True)

However, I'm being met with:

APIError: PlaceOrdersWithReceipt Params: { 'Orders': { 'Order': [ { 'SelectionId': 82026914, 'Stake': 2.0, 'Price': 2.4, 'Polarity': <Polarity.back: 1>, 'ExpectedSelectionResetCount': 0, 'ExpectedWithdrawalSequenceNumber': 0, 'KillType': <OrderKillType.FillOrKillDontCancel: 4>, 'FillOrKillThreshold': 0.0, 'CancelOnInRunning': <Boolean.T: 'true'>, 'CancelIfSelectionReset': <Boolean.T: 'true'>, 'WithdrawalRepriceOption': <WithdrawRepriceOption.Cancel: 2>, 'ExpiresAt': None, 'RestrictOrderToBroker': None, 'ChannelTypeInfo': None, 'PunterReferenceNumber': 1 } ] } } Exception: Server was unable to read request. ---> There is an error in XML document (10, 69). ---> Input string was not in a correct format.

I'm not sure how to check (10, 69) in the XML document... Do you have any idea where I'm going wrong here? Or might you have a sample of code where you're simply creating and placing an order that I could use?

Thanks a lot Matt

kauto23 avatar Jul 15 '18 11:07 kauto23

Sometimes I need to replace the enums with the values.

E.g. Boolean.T.value, rather than Boolean.T

jsphon avatar Apr 01 '19 18:04 jsphon

Hi, I have a similar error placing an order:

from betdaq.apiclient import APIClient
from betdaq.filters import create_order


order = create_order(96306047, 5.00, 2.10, betdaq_py.enums.Polarity.back.value, 0, 0)
api.api.betting.place_orders([order], receipt=True)

getting this error:

Traceback (most recent call last):
  File "C:\Users\haenec\AppData\Local\Continuum\anaconda3.5\envs\comeon\lib\site-packages\betdaq\endpoints\baseendpoint.py", line 26, in request
    response = self.client.secure_client.service[method](params)
  File "C:\Users\haenec\AppData\Local\Continuum\anaconda3.5\envs\comeon\lib\site-packages\zeep\client.py", line 41, in __call__
    self._op_name, args, kwargs)
  File "C:\Users\haenec\AppData\Local\Continuum\anaconda3.5\envs\comeon\lib\site-packages\zeep\wsdl\bindings\soap.py", line 120, in send
    return self.process_reply(client, operation_obj, response)
  File "C:\Users\haenec\AppData\Local\Continuum\anaconda3.5\envs\comeon\lib\site-packages\zeep\wsdl\bindings\soap.py", line 173, in process_reply
    return self.process_error(doc, operation)
  File "C:\Users\haenec\AppData\Local\Continuum\anaconda3.5\envs\comeon\lib\site-packages\zeep\wsdl\bindings\soap.py", line 275, in process_error
    detail=fault_node.find('detail'))
zeep.exceptions.Fault: Server was unable to read request. ---> There is an error in XML document (10, 149). ---> Input string was not in a correct format.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\haenec\AppData\Local\Continuum\anaconda3.5\envs\comeon\lib\site-packages\betdaq\endpoints\betting.py", line 91, in place_orders
    response = self.request(method, params, secure=True)
  File "C:\Users\haenec\AppData\Local\Continuum\anaconda3.5\envs\comeon\lib\site-packages\betdaq\endpoints\baseendpoint.py", line 32, in request
    raise APIError(None, method, params, e)
betdaq.exceptions.APIError: PlaceOrdersWithReceipt
Params: {
    'Orders': {
        'Order': [
            {
                'SelectionId': 96306047,
                'Stake': 5,
                'Price': 2.1,
                'Polarity': 1,
                'ExpectedSelectionResetCount': 0,
                'ExpectedWithdrawalSequenceNumber': 0,
                'KillType': <OrderKillType.FillOrKillDontCancel: 4>,
                'FillOrKillThreshold': 0.0,
                'CancelOnInRunning': <Boolean.T: 'true'>,
                'CancelIfSelectionReset': <Boolean.T: 'true'>,
                'WithdrawalRepriceOption': <WithdrawRepriceOption.Cancel: 2>,
                'ExpiresAt': None,
                'RestrictOrderToBroker': None,
                'ChannelTypeInfo': None,
                'PunterReferenceNumber': 1
            }
        ]
    }
}
Exception: Server was unable to read request. ---> There is an error in XML document (10, 149). ---> Input string was not in a correct format.

Thanks a lot Christoph

chaene82 avatar Apr 03 '19 12:04 chaene82

Cristoph, what happens if you replace the KillType with 4, CancelOnInRunning with 'true', 'CancelIfSelectionReset' with 'true' and WithdrawRepriceOption with '2'

i.e.

[
            {
                'SelectionId': 96306047,
                'Stake': 5,
                'Price': 2.1,
                'Polarity': 1,
                'ExpectedSelectionResetCount': 0,
                'ExpectedWithdrawalSequenceNumber': 0,
                'KillType': 4,
                'FillOrKillThreshold': 0.0,
                'CancelOnInRunning': 'true',
                'CancelIfSelectionReset': 'true',
                'WithdrawalRepriceOption': 2,
                'ExpiresAt': None,
                'RestrictOrderToBroker': None,
                'ChannelTypeInfo': None,
                'PunterReferenceNumber': 1
            }
        ]

jsphon avatar Apr 03 '19 13:04 jsphon

Works perfect. Many thanks.

chaene82 avatar Apr 03 '19 13:04 chaene82