1

(https://i.sstatic.net/xgoMx.jpg) I want to be able to pass a variable through to where the registration plate (AA19AAA) is

Overall, I want a function to check the number plate, therefore I need to pass a parameter through the function and use it in the payload, but I'm not sure how to actually pass a string to the inside of the payload.

I have tried using .format(...) to add things to the string, concatenating the variable into the payload, and another method similar to .format(...). However, if you believe any of these could be applicable, please don't hesitate to tell me as I may have made a mistake somewhere.

I hope some of you can assist me in this, I'm sorry if there is an incredibly simple solution to this, but I have tried a few, and feel that it is time to ask the professionals. Thank you so much

3
  • Please don't post code/errors/data as images. Commented Jan 23, 2023 at 23:41
  • It's unclear what the problem is exactly? The image shows some code that has the rego in there, are you asking how you can create a template that allows you to call the web service with varying license plate numbers? You say you tried .format(), can you share what you tried and explain what happened, and what you expected/wanted? Commented Jan 23, 2023 at 23:44
  • Does this answer your question? Python Request Post with param data Commented Jan 24, 2023 at 0:05

1 Answer 1

0

you have 2 options:

import requests
import json
payload = {'registrationNumber': some_var}
headers = {..., 'content': 'application/json'}
result = requests.post(url, headers = headers, data=json.dumps(payload))

or

import requests
headers = {...}
payload = {'registrationNumber': some_var}
result = requests.post(url, headers=headers, json=payload)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.