My query is not working

Leyner_B
Helper

My query is not working

Hi I am a Python developer triying to make an api call to the "Digital Card and Account Services" and the  "Visa Merchant Offers Resource Center" using the lines of code below, but I',m getting a "TypeError: encoding without a string argument"

 

How can I fix it?

 

url="https://sandbox.api.visa.com/vmorc/offers/v1/all"

encabezado = {'Accept':'application/json','Authorization':{'base64 encoded userid':base64.b64encode(bytes(os.open("/home/labop/Documents/virtualEnv/visaUno/visaAmbiente/app/key_#####-#####-########-#############.pem",os.O_RDWR|os.O_CREAT), 'utf-8'),'utf-8')}}
response = requests.get(url, headers=encabezado)
print(response.content)

 

 

 

3 REPLIES 3
API_Products
Visa Developer Support Specialist

Re: My query is not working

Hi,

 

Thanks for being part of the Visa Developer Community! In order for us to further investigate the issue, can you please provide more information on the error you have received, including the response request of the error received, screenshot and the Correlation ID? Please send this information to Developer@visa.com

Below are the steps to get the Correlation ID using a Google Chrome browser.

1>Open Chrome menu.
2>Click on More tools then Developer tools.
3>Check the box to Preserve Log for the Network Tab.
4>Then try to click on the add API link.
5>You can find the Correlation ID in the network log for add API call.

 

Thank you,

Diana




Thanks,

Diana H.



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

Leyner_B
Helper

Re: My query is not working

so, I tried to use this code:

https://github.com/visa/SampleCode/issues/29

so my current version of the code is this


@app.route('/Segunda_ProbarVisaApi', methods=['GET', 'POST'])
def Segundaspruebasvisasan():
#guia
#https://github.com/visa/SampleCode/issues/29
user_id = 'WXQ7YB73Z44N1SWO5J912168-HImYxZfh0y3GtMHoDIeFEQuo'
password = 'ViC09RFXp9S0'

headers = {'content-type': 'application/json', 'accept':'application/json'}
body='''{
}'''

base_uri = 'vmorc/offers/'
resource_path = 'v1/all/'
url = 'https://sandbox.api.visa.com/' + base_uri + resource_path

r = requests.get(url,
cert = ('/home/labop/Documents/virtualEnv/visaUno/visaAmbiente/app/key_58f6245f-d3d8-4268-90e7-c18dcfe70e53.pem','what do I get my private ket?????'),
headers = headers,
auth = (user_id, password))

print(r.status_code)
data=json.loads(r.content)

when I executed, I recevied the error below (the part highlighted in res)


requests.exceptions.SSLError: HTTPSConnectionPool(host='sandbox.api.visa.com', port=443): Max retries exceeded with url: /vmorc/offers/v1/all/ (Caused by SSLError(SSLError(336445449, '[SSL] PEM lib (_ssl.c:2825)'),))

but the code in the link is this, what should I put in the highlighted part of the code below?????? I am missing the privateKey o the cert.pem???? and where do I get what I lack???



import json
import requests

user_id = 'AZP29ZAILMIJQ4YFGQ3M21R0QnnV1_Qy-ZhrCHDPLlT-MjkrA'
password = '1LA4R5rGGK5vymUsp75JAVHprEjGlAgH'

headers = {'content-type': 'application/json', 'accept':'application/json'}
body='''{
}'''

base_uri = 'vmorc/offers/'
resource_path = 'v1/all/'
url = 'https://sandbox.api.visa.com/' + base_uri + resource_path

r = requests.get(url,
cert = ('cert.pem','privateKey.pem'),
headers = headers,
auth = (user_id, password))

print r.status_code
data=json.loads(r.content)
API_Products
Visa Developer Support Specialist

Re: My query is not working

Hi,

 

Thanks for helping the Visa Developer Community every time you post questions and solutions to this forum! Can you please refer to this community forum post on how to get the key via this link - https://community.developer.visa.com/t5/Getting-Started-with-Visa/Could-not-create-SSL-TLS-Secure-Ch...

 

Thank you,

Diana




Thanks,

Diana H.



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.