0

How to solve python POST response 405?

import requests
import json

from requests.auth import HTTPBasicAuth
myHeaders = { 'accept': 'application/json', 'content-type': 'application/json', 'X-Killbill-CreatedBy': 'demo', 'authorization':'Basic YWRtaW46cGFzc3dvcmQ=', 'X-Killbill-ApiKey': 'abcd', 'X-Killbill-ApiSecret': 'dcba'}

myData = {'transactionType': 'AUTHORIZE', 'amount': 23, 'currency': 'INR', 'transactionExternalKey': 'python003' }

myParams = {'paymentMethodId': '810d4eae-4668-4c6a-897c-178c041eb67f'}

response=requests.get(
    'http://192.168.12.80:8080/1.0/kb/accounts/a6c08c2c-f3eb-456a-a681-6e5262262e94',
    params = myParams,
    headers = myHeaders,
    data = json.dumps(myData),
)
print(response)
kenlukas
  • 2,886
  • 2
  • 14
  • 25
  • HTTP 405 means method not allowed. You said about python POST, but your code uses "response=requests.get(...". Try replacing that by line by "response=requests.post(...". – JucaPirama Nov 20 '19 at 20:33

1 Answers1

1

405 status code response means the HTTP method you are trying is not allowed. Say, if a PUT request is not allowed on a server, it will reject the client's PUT request with an response code 405 Method not allowed.

So, in your case also, the POST method might not be allowed on which you are sending the request and the request is simply denying you to make any POST request by sending 405 error response.

Samit
  • 121
  • 4