Using API via Python
Using API via Python
- Casa
- Pannello di controllo
- Forum della Comunità
- Services
- Dynamic DNS Service
- Using API via Python
- Forum della Comunità
- Using API via Python
Argomento: Using API via Python
Bash works but I cannot seem to get it to work via python. The debug output from debug is below after the python source code. Have I made any obvious errors?#!/usr/bin/env bashVAL=`curl -X POST https://api.dynu.com/v2/dns/{ID}/record/{RID} -H "accept: application/json" -H "API-Key: {KEY}" -d "{ \"nodeName\": \"_acme-challenge\", \"recordType\": \"TXT\", \"state\": true, \"textData\": \"DATA\" }"`echo $VAL | python -m json.toolReponse:{ "statusCode": 200, ... }======#!/usr/bin/env python import requestsurl = "https://api.dynu.com/v2/dns"hostid = {ID}recordid = {RID}type = "record"url = url +"/"+ str(hostid) +"/"+ type +"/"+ str(recordid);header = { "accept": "application/json", "API-Key": "{KEY}"}pd = { "nodeName": "_acme-challenge", "recordType": "TXT", "state": "true", "textData": "Python"}response = requests.post(url, data=pd, headers=header)Response:{'accept': 'application/json', 'API-Key': '{{KEY}'}{'nodeName': '_acme-challenge', 'recordType': 'TXT', 'state': 'true', 'textData': 'Python'}https://api.dynu.com/v2/dns/{ID}/record/{RID}DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.dynu.com:443send: b'POST /v2/dns/{ID}/record/{RID} HTTP/1.1\r\nHost: api.dynu.com\r\nUser-Agent: python-requests/2.32.1\r\nAccept-Encoding: gzip, deflate\r\naccept: application/json\r\nConnection: keep-alive\r\nAPI-Key: {KEY}\r\nContent-Length: 66\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n'send: b'nodeName=_acme-challenge&recordType=TXT&state=true&textData=Python'reply: 'HTTP/1.1 501 Argument Exception\r\n'header: Date: Thu, 13 Jun 2024 18:58:25 GMTheader: Server: Dynu Web Serverheader: X-Powered-By: Dynu Dynamic DNS Serviceheader: Cache-Control: no-storeheader: Pragma: no-cacheheader: Content-Length: 67header: Content-Type: application/json; charset=UTF-8DEBUG:urllib3.connectionpool:https://api.dynu.com:443 "POST /v2/dns/{ID}/record/{RID} HTTP/1.1" 501 67
Rispondi con citazione | Segnalare
Autore | Argomento: Using API via Python |
---|---|
vier Iscritto: 26/09/2016 |
Using API via Python giovedì 13 giugno 2024 12:06
Bash works but I cannot seem to get it to work via python. The debug output from debug is below after the python source code. Have I made any obvious errors?#!/usr/bin/env bashVAL=`curl -X POST https://api.dynu.com/v2/dns/{ID}/record/{RID} -H "accept: application/json" -H "API-Key: {KEY}" -d "{ \"nodeName\": \"_acme-challenge\", \"recordType\": \"TXT\", \"state\": true, \"textData\": \"DATA\" }"`echo $VAL | python -m json.toolReponse:{ "statusCode": 200, ... }======#!/usr/bin/env python import requestsurl = "https://api.dynu.com/v2/dns"hostid = {ID}recordid = {RID}type = "record"url = url +"/"+ str(hostid) +"/"+ type +"/"+ str(recordid);header = { "accept": "application/json", "API-Key": "{KEY}"}pd = { "nodeName": "_acme-challenge", "recordType": "TXT", "state": "true", "textData": "Python"}response = requests.post(url, data=pd, headers=header)Response:{'accept': 'application/json', 'API-Key': '{{KEY}'}{'nodeName': '_acme-challenge', 'recordType': 'TXT', 'state': 'true', 'textData': 'Python'}https://api.dynu.com/v2/dns/{ID}/record/{RID}DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.dynu.com:443send: b'POST /v2/dns/{ID}/record/{RID} HTTP/1.1\r\nHost: api.dynu.com\r\nUser-Agent: python-requests/2.32.1\r\nAccept-Encoding: gzip, deflate\r\naccept: application/json\r\nConnection: keep-alive\r\nAPI-Key: {KEY}\r\nContent-Length: 66\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n'send: b'nodeName=_acme-challenge&recordType=TXT&state=true&textData=Python'reply: 'HTTP/1.1 501 Argument Exception\r\n'header: Date: Thu, 13 Jun 2024 18:58:25 GMTheader: Server: Dynu Web Serverheader: X-Powered-By: Dynu Dynamic DNS Serviceheader: Cache-Control: no-storeheader: Pragma: no-cacheheader: Content-Length: 67header: Content-Type: application/json; charset=UTF-8DEBUG:urllib3.connectionpool:https://api.dynu.com:443 "POST /v2/dns/{ID}/record/{RID} HTTP/1.1" 501 67
|
Al momento è sabato 12 ottobre 2024 12:08 US Mountain Standard Time
sabato 12 ottobre 2024 12:08