httprequest

How to send accented characters with diacritics in HTTP request-payload?

How to send accented characters with diacritics in HTTP request-payload? Question: I am requiring to send special characters like accented characters with diacritics, e.g. o-acute รณ, via API This is my test code import string import http.client import datetime import json def apiSendFarmacia(idatencion,articulo,deviceid): ##API PAYLOAD now = datetime.datetime.now() conn = http.client.HTTPSConnection("apimocha.com") payload = json.dumps({ "idatencion": …

Total answers: 1

Response code 404 in python requests, opens normally in the browser

Response code 404 in python requests, opens normally in the browser Question: I’m trying to requests.get this page in python requests but get error code 404. It opens normally in the browser. What’s wrong here? requests.get(‘https://www.shararam.ru/su/Build/2022.09.20.json’) <Response [404]> Asked By: the_oceanor || Source Answers: try with requests session: import requests from bs4 import BeautifulSoup url …

Total answers: 2

Why am I getting a redirect loop with this python program?

Why am I getting a redirect loop with this python program? Question: I’m trying to get a url using python requests. requests.get(‘https://google.com’) works fine but then I add my custom headers and get a redirect loop, why? import requests s = requests.Session() s.headers = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "Accept-Encoding": "gzip, deflate", "Accept-Language": "en-US,en", "Host": "google.com", "Upgrade-Insecure-Requests": …

Total answers: 2

GET Request with JS

GET Request with JS Question: i need to send a GET request from my JavaScript function to my python flask app. However, i tried to type the URL with the parameters manually and it worked. But i can’t send the same request in a JS function. Response type is HTML. This is how the URL …

Total answers: 2

How to call a view from within itself in a Django REST API?

How to call a view from within itself in a Django REST API? Question: I have this function in my Django REST API that handles the insertion of products. Sometimes a product will be a variational product (when product.type = 3), in which case I get all the permutations of these variations and want to …

Total answers: 1

How to get the origin URL in FastAPI?

How to get the origin URL in FastAPI? Question: Is it possible to get the URL that a request came from in FastAPI? For example, if I have an endpoint that is requested at api.mysite.com/endpoint and a request is made to this endpoint from www.othersite.com, is there a way that I can retrieve the string …

Total answers: 2

How can I send an HTTP request from my FastAPI app to another site (API)?

How can I send an HTTP request from my FastAPI app to another site (API)? Question: I am trying to send 100 requests at a time to a server http://httpbin.org/uuid using the following code snippet from fastapi import FastAPI from time import sleep from time import time import requests import asyncio app = FastAPI() URL= …

Total answers: 2

websocket vs rest API for real time data?

websocket vs rest API for real time data? Question: I need to constantly access a server to get real time data of financial instruments. The price is constantly changing so I need to request new prices every 0.5 seconds. The REST APIs of the brokers let me do this, however, I have noticed there’s quite …

Total answers: 1

Python3.4 read content stream web request

Python3.4 read content stream web request Question: How, in Python3.4, can I read the data from a web request which has an event-stream as content type? The stream data is updated every 30 seconds and for each of them I would extract and process data. Example: I performed a request on http://example.com/value121 In the headers, …

Total answers: 2