I am trying to do a fetch() post and send a FormData object and an Int. I can do one or the other but when trying to send both I get unrelating 415 status codes.
My post data looks like:
var payload = {
documents: documents, // which is of type new FormData()
applicationId: applicationId // which is of type int
}
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`
},
body: payload
And my c# backend looks like below:
[HttpPost]
public async Task<JsonResult> UploadDocuments(DocumentUploadVm payload)
below is my request headers:
:authority: localhost:44343
:method: POST
:path: /api/expert/UploadDocuments
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
authorization: Bearer eyJraWQiOiJYNnplamszSy10RjBkMmtWYXpHNE84aFNsUGtSSklhT1ZMeGQ3dC1tQ21FIiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULnRuaGFQVGp5RnY4eEhMaGFVM18zLW5rdlVLWV9QUEw5aXJTczI4NHF3c3ciLCJpc3MiOiJodHRwczovL2Rldi04NzAzMTAub2t0YS5jb20vb2F1dGgyL2RlZmF1bHQiLCJhdWQiOiJhcGk6Ly9kZWZhdWx0IiwiaWF0IjoxNjAwNjQ0MzAzLCJleHAiOjE2MDA2NDc5MDMsImNpZCI6IjBvYXAzbmdtNG1BUDBTT1YzNHg2IiwidWlkIjoiMDB1ZGFudnVpUjB6SHp6emk0eDYiLCJzY3AiOlsicHJvZmlsZSIsImdyb3VwcyIsImVtYWlsIiwib3BlbmlkIiwicGhvbmUiXSwic3ViIjoiZGFuaWVsOTVicm93bkBnbWFpbC5jb20ifQ.0ya1CTLuPQcPLyXgph7TQMzwhWtUWrb1QzQx6G2kS4X5fawXZ13XFIztG2TMjCIrTrbGa1WPx-hYmqI7EB2Eilhp0ekQKt85U7Q3Ug5HuQQMhrH8KjvHF5fhElNwf5z1vp4Zgtg1MbF-MPetoV4ttG3SQwxLJ-SFHZFkA-HY2lzoMQS-40V53q5ruVbeXEpX8iwhSXzA7mp53YEaSNWecDJxHoBy6yXszrJrpkQ1wqsp9p5ti1XASVczlLkL-J-IOx6Rf61LfPH9_Q4KR3aZsd_peInJF14YF0lLesmxcnQcvbdMGsUO0PrPtku8wQEeuuQGYn-zZR5eBSDR9ZbzLw
content-length: 15
content-type: text/plain;charset=UTF-8
origin: http://localhost:8080
referer: http://localhost:8080/expert/register
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: cross-site
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
I have tried using the [FromBody],[FromForm] tags, stringifying and everything in between to no avail. Any help would be greeeeeeeatly appreciated as I am losing my mind.
I am using selenium and requests aimed at getting some data from a website. Since the data is acquired by Ajex request, I decided to use requests to imitate the post request. Some parameters are needed in this case. Chrome checking results are as follows:
:authority: www.miaomiaozhe.com
:method: POST
:path: /api/pricehistory/getUrlPriceHistory
:scheme: https
accept: /
accept-encoding: gzip, deflate, br
accept-language: zh-CN,zh;q=0.9
content-length: 3284
content-type: application/x-www-form-urlencoded; charset=UTF-8
cookie: HZBID=db556a075167c32227609e6871911beb; gr_user_id=bd42c97e-3291-4b18-bc37-0c12b367967d;
PHPSESSID=qsksp6v3t4m7880j0ptjshc7u7; MMZUFLAG=104163326; MMZUSS=3531fecdefc1b40c34c9b568cde18326; gr_session_id_b49be8fba0e9e60a=74e18968-dad1-449d-b248-71c2b2d855cd; gr_session_id_b49be8fba0e9e60a_74e18968-dad1-449d-b248-71c2b2d855cd=true
origin: https://www.miaomiaozhe.com
referer: https://www.miaomiaozhe.com/pricehistory
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36
x-requested-with: XMLHttpRequest
Above are the request headers of the post.
and the form data is as follows:
As is shown in the picture, there is a parameter named nvcVal in the post.
by checking the JS codes of the website, I found it's from nvcVal: window.getNVCVal().
so I coded the following codes to get the data.
from time import sleep
import requests
import json
chrome_opt = webdriver.ChromeOptions()
prefs = {"profile.managed_default_content_settings.images": 1}
# chrome_opt.add_experimental_option("prefs", prefs)
# chrome_opt.add_experimental_option('excludeSwitches', ['enable-automation'])
chrome_opt.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36"')
driver = webdriver.Chrome(chrome_options=chrome_opt)
driver.get("https://www.miaomiaozhe.com/pricehistory")
# driver.find_element_by_class_name('pl').click()
good3 = "https://detail.tmall.com/item.htm?spm=a220m.1000858.1000725.1.e748471bZmg76Q&id=594572481181&skuId=4360012669001&areaId=420100&user_id=1809177149&cat_id=2&is_b=1&rn=04e4c83fcb68c340abf88983da82b1b7"
good2 = "https://detail.tmall.com/item.htm?spm=a220m.1000858.1000725.7.e748471bIRN6jQ&id=554640570620&skuId=4341085905022&areaId=420100&user_id=2928380385&cat_id=2&is_b=1&rn=6ba9712cf53485a574d73191e05d0cbf"
goodURL = "https://detail.tmall.com/item.htm?id=569343149791&spm=875.7931836/B.2017081.2.66144265gU7Lgd&scm=1007.12144.81309.73299_0_0&pvid=10ae9600-6e84-4ad0-8e1e-a8379cea71c3&utparam=%7B%22x_hestia_source%22:%2273299%22,%22x_object_type%22:%22item%22,%22x_mt%22:9,%22x_src%22:%2273299%22,%22x_pos%22:1,%22x_pvid%22:%2210ae9600-6e84-4ad0-8e1e-a8379cea71c3%22,%22x_object_id%22:569343149791%7D"
driver.find_element_by_id('ipt').send_keys(good3)
# driver.find_element_by_id('search-btn').click()
sleep(2)
js = " return window.getNVCVal()"
nvcVal = driver.execute_script(js)
print("nvcVal = "+str(nvcVal))
# new_nvcVal = "%7B%22a%22%3A%22FFFF0N0N000000006AFF%22%2C%22c%22%3A%221590723506842%3A0.99342660331515%22%2C%22d%22%3A%22nvc_activity%22%2C%22h%22%3A%7B%22key1%22%3A%22code0%22%2C%22nvcCode%22%3A400%2C%22umidToken%22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.execute_script("return " + ajax_query)
url = "https://www.miaomiaozhe.com/api/pricehistory/getUrlPriceHistory"
data = {'url': good3, 'nvcVal': nvcVal}
header = {"authority": "www.miaomiaozhe.com", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36"}
# cookie = {"HZBID":"db556a075167c32227609e6871911beb", "gr_user_id":"bd42c97e-3291-4b18-bc37-0c12b367967d", "PHPSESSID":"qsksp6v3t4m7880j0ptjshc7u", "MMZUFLAG":"104163326", "MMZUSS":"3531fecdefc1b40c34c9b568cde18326", "gr_session_id_b49be8fba0e9e60a":"c1c318c3-8db5-4bbd-8f78-e893b0dea1ec", "gr_session_id_b49be8fba0e9e60a_c1c318c3-8db5-4bbd-8f78-e893b0dea1ec":"true"}
req = requests.post(url, data, headers=header)
print(req.text)
driver.close()'''
I failed, unawaring what's been wrong.
I guess it could be the problem of the parameter of nvcVal, but I don't have any idea how I can get it right.
I am trying to do this simple(?) thing:
in a test page ("/test") send some parameters to the server using POST
when the view detects some those parameters, redirect to home ("/")
I can get this to work but only if I post the values using a form, it does not work if I run a javascript function calling a xmlhttprequest. I used the cookiecutter-starter and just added some lines.
__init__.py
from pyramid.config import Configurator
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.include('pyramid_chameleon')
config.add_static_view('static', 'static', cache_max_age=0)
config.add_route('home', '/')
config.add_route('test', '/test')
config.scan()
return config.make_wsgi_app()
views.py
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound,HTTPSeeOther
#view_config(route_name='home', renderer='templates/mytemplate.pt')
def my_view(request):
print("in my view")
return {'project': 'project'}
#view_config(route_name='test', renderer='templates/jg.pt')
def y_view(request):
prm_0 = request.POST.get("prm_0",None)
prm_1 = request.POST.get("prm_1",None)
if prm_0 and prm_1:
print("parameters present")
return HTTPFound(location=request.route_url("home"))
else:
print("no parameters found")
return {}
templates/jg.pt
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:tal="http://xml.zope.org/namespaces/tal" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>n</title>
<script type="text/javascript">
function postit(){
console.log("pompom");
var xhr = new XMLHttpRequest();
xhr.open("POST", '/test', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
xhr.send("prm_0=898&prm_1=603");
}
</script>
</head>
<body>
using XMLHttpRequest..
<br/>
<button onclick="postit()">through xmlhttprequest</button>
<br/>
wrapped in a form...
<form method="POST">
<input type="hidden" name="prm_0" value="3455">
<input type="hidden" name="prm_1" value="6778">
<button type="submit">in-form</button>
</form>
</body>
When i press the button for the xhr i see in browser development tool 2 requests:
name=test, status=302, type=text,html
name=localhost, status=200, type=xhr
I can see in the console that the view callable for home is called (prints "in my view") but it does not render.
Now, when i press the form button i see in browser development tools many requests, being the most important:
name=test, status=302, type=text,html
name=localhost, status=200, type=document
and this time it does render the home page.
I tried adjusting the xhr so the headers look like the other request.
Request header sent using xhr button:
test page
POST /test HTTP/1.1
Host: localhost:6543
Connection: keep-alive
Content-Length: 19
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Origin: http://localhost:6543
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.54
Content-Type: application/x-www-form-urlencoded
Referer: http://localhost:6543/test
Accept-Encoding: gzip, deflate, br
Accept-Language: es-419,es;q=0.9
Cookie: pdtb_active=performance
home page
GET / HTTP/1.1
Host: localhost:6543
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.54
Referer: http://localhost:6543/test
Accept-Encoding: gzip, deflate, br
Accept-Language: es-419,es;q=0.9
Cookie: pdtb_active=performance
Now using the form button:
test page
POST /test HTTP/1.1
Host: localhost:6543
Connection: keep-alive
Content-Length: 21
Pragma: no-cache
Cache-Control: no-cache
Origin: http://localhost:6543
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.54
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://localhost:6543/test
Accept-Encoding: gzip, deflate, br
Accept-Language: es-419,es;q=0.9
Cookie: pdtb_active=performance
home page
GET / HTTP/1.1
Host: localhost:6543
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.54
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://localhost:6543/test
Accept-Encoding: gzip, deflate, br
Accept-Language: es-419,es;q=0.9
Cookie: pdtb_active=performance
They look the same!
Why is one interpreted as xhr and other as document?
I am thinking that if I get the xhmbutton generated request to be treated as document it may be rendered, am I right? Is this it? I think I read somewhere that the page is not rendered because of the raised exception (httpfound) but if it is so, how or when will it work?
In Calling another view in Pyramid some suggested using "render_to_response" or "subrequests", I tried without success and looking at the examples, none of them uses a declarative style for the views, what makes me think that the response that these options generate cannot be well-handled by the renderer.
What is the correct way of accomplishing this? Should I stick to forms? Why does form works but the other does not?
Duplicate? There is a little but important difference to
Calling another view in Pyramid
being that in my case I use the declarative style and the return values of the views go through the renderer defined in the decorator. I think that makes the answers of the other thread unfit for this one.
I got the answer in the pylons-discuss mail group. If i understand correctly the POST made from javascript is not the same that the POST made using the form. For this to work, javascript has to make the redirection.
changing the js script to redirect after completion it works well:
<script type="text/javascript">
function postit(){
console.log("pompom");
var xhr = new XMLHttpRequest();
xhr.open("POST", '/test', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
xhr.setRequestHeader("Upgrade-Insecure-Requests", 1);
xhr.send("prm_0=898&prm_1=603");
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
window.location.replace("/");
}
};
}
</script>
I'm using FileUploader UI5 element to upload a file using XMLHttpRequest (POST operation), here below is my code snippet -
var input = document.querySelector('input[type="file"]');
var data = new FormData();
data.append("files", input.files[0]);
var xhr = new XMLHttpRequest();
xhr.open("POST","https://URL");
xhr.setRequestHeader('Content-Type', 'multipart/form-data');
xhr.setRequestHeader("apikey", "XXXXXXXXXXXXXXXXX");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);
But while pushing a request, i am getting below exception. Not sure why my post operation is getting failed, any help would be appreciated.
error description - This service requires at least 1 file. Please put your file(s) into the files field of the POST request"
This is how the request header and payload looks like -
Request Header -
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8
apikey:RGIukzqxB0GWhRaMMcCTmYGHnEWgk5qI
Connection:keep-alive
Content-Length:15
Content-Type:text/plain;charset=UTF-8
Host:sandbox.api.sap.com
Origin:https://webidetesting2532276-be010f3f7.dispatcher.us1.hana.ondemand.com
Referer:https://webidetesting2532276-be010f3f7.dispatcher.us1.hana.ondemand.com/extended_runnable_file.html?hc_orionpath=%2Fbe010f3f7%24S0015741697-OrionContent%2Fsap.ui.unified.sample.FileUploaderComplex&origional-url=index.html&sap-ui-appCacheBuster=&sap-ui-xx-componentPreload=off
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
Request Payload -
[object Object]
You've explicitly set the Content-Type but it is missing the MIME boundary parameter. Omit the header entirely and allow XHR to infer the Content-Type from the FromData object.
I want to extract specific values from http request headers, below is an example of the header information
GET ***/agencychannel-uiapiservices/api/ken/AccountProfile/GetAccountProfileWithViewingPeriod*** HTTP/1.1
Cookie: __utma=132118163.703100490.1447412805.1456837339.1458655276.3; _em_vt=98cf395181af797bbccffc582cf957fe2438c7f254-0905822558184c34; A03RNB-PHRS2-80-PORTAL-PSJSESSIONID=a1Sfb2ZGJdR4VlBvyDvRDxSHOseo9kZa!-351035759; https%3a%2f%2fpeoplesoft.multichoice.co.za%2fpsp%2fhrprd%2femployee%2fhrms%2frefresh=list:%20%3Ftab%3Dhc_ux_manager_dashboard%7C%3Frp%3Dhc_ux_manager_dashboard%7C%3Ftab%3Dhc_talent_summary%7C%3Frp%3Dhc_talent_summary%7C%3Ftab%3Dremoteunifieddashboard%7C%3Frp%3Dremoteunifieddashboard
Host: ***apidtgateway.multichoice.co.za:9800***
Accept: */*
Content-Type: application/json
Accept-Language: en-ZA,en-GB;q=0.8,en-US;q=0.6,en;q=0.4
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36
Connection: keep-alive
komodo-sessiontoken: a2f960a2-f359-4ed9-a926-41630d37ae06
Accept-Encoding: gzip, deflate, sdch
When I get the request I need to extract the host and the path, end results should be like this apidtgateway.multichoice.co.za:9800/agencychannel-uiapiservices/api/ken/AccountProfile/GetAccountProfileWithViewingPeriod
Example
function TControllerAplicacao.EchoString(Value: string): string;
var
objWebModule: TWebModule; //need Web.HTTPApp
host :string;
xxx :string;
begin
objWebModule := GetDataSnapWebModule; //need Datasnap.DSHTTPWebBroker
host := objWebModule.Request.host;
//see on Delphi IDE other possibilities, code complete will show to you)
//key header that you know the name, is possible to be custom header:
xxx := objWebModule.Request.GetFieldByName('Content-Type');
Result := Value; //from original datasnap example EchoString
end;