I am using $http.get mthod to hit the mysql services to get the records of particulars table, even post and put is working fine. it fails on get method.
In request header we have like this
Provisional headers shown
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:accept, authorization
Access-Control-Request-Method:GET
Host:d.example.com
Origin:http://localhost
Referer:http://localhost/xxxx/
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
It shows "Provisional headers shown" error if this error happens it fails the api. can you give some suggestions where it goes wrong , actually i set all the headers in mysql services
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Accept: text/html,application/json,text/plain");
header("Content-Type: application/json");
I found a solutions ....
Actually am using two services one for mysql and other for micro service mongoDB
So the problem is passing authentication header for mysql , now i remove the header for mysql service calls and the problem solved.
using below code
$http.defaults.headers.common = {};
Which may help for others.
Related
I'm storing my static files on different domain and I want my remote static server returns files with CORS headers, but my server should get "Origin" header in request to allow CORS headers. Unfortunately Chrome and FF doesn't send this header when I try load my js script with usual
<script type="text/javascript" src="https://my-another-static-server.com/js/script.js"></script>
When I see in Chrome's network panel I see only these request headers for this request:
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:ru,en-US;q=0.8,en;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Host:my-another-static-server.com
Pragma:no-cache
Referer:http://localhost:63342/example.html
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
I know that browsers add Origin header for cross-domain request if we use XMLHttpRequest, but here we send request with native browsers technology.
There is tag crossorigin=anonymous that solved this problem. Now when I load script my browser also send Origin header.
I'm using postman and dreamfactory and I get the following error message, when I send a post request to create a record in a table. I'm using MySQL as my database. I believe it could be because I haven't set up my foreign key relationships properly. How can I go about setting this up?
Invalid schema detected - no type or db_type element.
Below is the request header
General
----
Remote Address:[::1]:8080
Request
URL:http://localhost:8080/api/v2/MySQL/_schema/kartadb.country/1
Request Method:POST
Status Code:500 Internal Server Error
Response Headers
view source
Access-Control-Allow-Origin:chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Cache-Control:no-cache
Connection:close
Content-Type:application/json
Date:Tue, 20 Oct 2015 08:17:33 GMT
Server:Apache
Transfer-Encoding:chunked
Vary:Origin
X-Frame-Options:SAMEORIGIN
X-Powered-By:PHP/5.5.29
Request Headers
----
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Authorization:Basic dGV3b2Ryb3Mud3JAZ21haWwuY29tOg==
Cache-Control:no-cache
Connection:keep-alive
Content-Length:92
Content-Type:text/plain;charset=UTF-8
Host:localhost:8080
Origin:chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Postman-Token:3f469a4f-f95a-eb1f-c5eb-8da94b110e47
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
X-DreamFactory-Api-Key:6498a8ad1beb9d84d63035c5d1120c007fad6de706734db9689f8996707e0f7d
X-DreamFactory-Session-Token:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjcsInVzZXJfaWQiOjcsImZvcmV2ZXIiOmZhbHNlLCJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA4MFwvYXBpXC92MlwvdXNlclwvc2Vzc2lvbiIsImlhdCI6IjE0NDUzMjY2OTQiLCJleHAiOiIxNDQ1MzMwMjk0IiwibmJmIjoiMTQ0NTMyNjY5NCIsImp0aSI6ImNlMDJiMWU1ZTRjZjc4MmZmYTYxZmYyZDM1MGNiODg2In0.F0UcNExumeAwLF-xM6SmgKktcPSprYrS7x95KFJmYI4
You mention creating a "record" in a table. The /_schema resource is for creating table schema, not records. Use the /_table resource for creating records.
I am working on a JavaScript application, where I want to read data from an XML file and post them into a HTML file.
My code is producing the following error:
Request URL:http://myServer/dirs/dir/scripts/xml_data.xml
Request Method:POST
Status Code:405 Method Not Allowed
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en,en-US;q=0.8,da;q=0.6
Connection:keep-alive
Content-Length:13
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Host:myServer
Origin:http://myServer
Referer:http://myServer/dirs/dir/inWork.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Dataview sourceview URL encoded
node:xnode-24
Response Headersview source
Allow:GET, HEAD, OPTIONS, TRACE
Cache-Control:private
Content-Length:5309
Content-Type:text/html; charset=utf-8
Date:Thu, 12 Feb 2015 21:06:08 GMT
Server:Microsoft-IIS/8.0
X-Powered-By:ASP.NET
Based on this posting I created a new 'Handler Mapping' and I also adjusted the 'Handler Mapping' for 'StaticFile' to allow the methods: GET,HEAD,POST,DEBUG,PUT,DELETE.
The IIS server was restarted but still the error message appears and the only methods allowed are: GET, HEAD, OPTIONS, TRACE.
So, there is some configuration file or 'Handler Mapping' overriding my settings, or I simply did not consider.
Any suggestions on how to tell the IIS to accept my settings for this XMLHttpRequest?
I have a Spring MVC application with a few REST interfaces exposed and is running on an Apache Tomcat instance.
I'm wondering if there are any ways to troubleshoot the data binding errors when trying to POST to an end point. So when I post some JSON I would like to find out why the data binding is failing (when Spring converts this to an object at the Controller). I might have to do some config changes to the apache server to increase the debugging level to show more info or increase the logging level in my application (log4j) to display any errors that Spring throws out. Wondering if anyone can help me find ways to debug databinding issues.
Here is the request/response log from the Chrome's dev console for the failed request. If I simplify the JSON structure, it does seem to bind but I'd like to find out which specific JSON attributes are causing the problem.
Request URL:http://localhost:8080/entryrive-service/user/6/entry/
Request Method:POST
Status Code:400 Bad Request
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:667
Content-Type:application/json;charset=UTF-8
Host:localhost:8080
Origin:http://localhost:8383
Referer:http://localhost:8383/entryrive-client/app/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Request Payloadview source
{id:null, title:Sprouts Farmers Market, entryDate:1388559600000, entryPayerId:[6], notes:test,…}
entryCreaterId: null
entryDate: 1388559600000
entryItemEntry: []
entryPayerId: [6]
entrySimpleEntry: {id:null, itemDescription:null, simpleUserIdAndLiableCost:[,…]}
entryTotal: "30"
groupId: 3
id: null
notes: "test"
title: "Sprouts Farmers Market"
userId: null
Response Headersview source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://localhost:8383
Connection:close
Content-Language:en
Content-Length:968
Content-Type:text/html;charset=utf-8
Date:Sun, 05 Jan 2014 19:50:05 GMT
Server:Apache-Coyote/1.1
Increasing the logging level of Spring framework did seem to show up what Spring has been upto
log4j.logger.org.springframework=ALL
I've built a web application using CORS for communicating with the API.
The API accept all origin and some headers and is written using Play!Framework.
On every request made to the app, I add these headers :
override def doFilter(action: EssentialAction): EssentialAction = EssentialAction { request =>
action.apply(request).map(_.withHeaders(
"Access-Control-Allow-Origin" -> "*",
"Access-Control-Allow-Methods" -> "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers" -> "Origin, X-Requested-With, Content-Type, Accept, Host, Api-Token"
))
}
Everything works great in Firefox and Chrome in the desktop (tested under Windows and Linux), but fails on my Android phone (using Chrome browser and the native browser).
I enabled the Chrome debugging via USB, and I can clearly see that Chrome doesn't go further than the OPTIONS request made to the server. Here's the request made :
Request URL:http://127.0.0.1:9100/auth/login
Request Headersview source
Access-Control-Request-Headers:accept, origin, x-requested-with, content-type
Access-Control-Request-Method:POST
Origin:http://192.168.0.15:9000
Referer:http://192.168.0.15:9000/login
User-Agent:Mozilla/5.0 (Linux; Android 4.1.1; HTC One S Build/JRO03C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.90 Mobile Safari/537.36
And it stops here, no response from the server (but the Network tabs indicate "Pending" for this request !).
So now I don't know what is wrong. How can I fix this problem ?
It may be a red herring, but I see in the headers you show the string:
Request URL:http://127.0.0.1:9100/auth/login
It seems to me that it tries to connect to localhost (127.0.0.1) but your mobile doesn't have a running server, so it fails.