Fetch request, authorization - html

In my web browser developer tools, I am trying a fetch request.
and am receiving a 401 (Unauthorized) error.
I know I have the correct credentials because it works in postman. Can you help me understand what is wrong? Maybe is the syntax?
I assume the error is within
{Authorization:'Basic YWIamnottypingouttherestofmycreds'}
but I have tried every variation of this, ie:
{'Authorization':'Basic YWIamnottypingouttherestofmycreds'}
{Authorization:Basic YWIamnottypingouttherestofmycreds}
{'Authorization':Basic YWIamnottypingouttherestofmycreds}
fetch("http:/someoneelsesite.com",{mode:"no-cors",headers:{Authorization:'Basic YWIamnottypingouttherestofmycreds'}}).then (a => a.text()).then(console.log)

Related

Autodesk-designautomation: Internal Server Error(Error Code 500): Missing parameter in WorkItem

I am using Autodesk Revit and have been trying to implement the Design Automation API. I have been successful in trying out the sample, modify-your-model tutorial where the dimensions of a window are altered. However the example code is not executing perfectly anymore and it displays an internal server error message(error code 500). The error console claims that some parameter in the workItem is missing. The code worked again on the morning of 14th March again, but by noon it started showing the same error. The error log on the web page and console are given below respectively.
My question is, has the Autodesk OSS server been down for some time now or is it some fault from my side? Please help me out.
P.S. The same code worked perfectly before. I have not edited anything. Yes, I did try changing the Client ID and Client Secret and also update the ngrok address every 2hours.
Sincerely
Error list
-Failed to load resource: the server responded with a status of 500 (Internal Server Error)
-No webpage was found for the web address: http://localhost:3000/api/forge/designautomation/workitems
error in debugger
-fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HM76OJJ532MV", Request id "0HM76OJJ532MV:00000002": An unhandled exception was thrown by the application.
System.Net.Http.HttpRequestException: The server returned the non-success status code 400 (Bad Request).
More error details:
{
"url": [
"Error converting value \"http://aa025317d1f2.ngrok.io /api/forge/callback/designautomation?id=76m1z2sw7uQi-jtAYzYvgA&outputFileName=20210314024133_output_revit_sample_file.rvt\" to type 'System.Uri'. Path 'url', line 1, position 2376."
],
"workItem": [
"A value for the 'workItem' parameter or property was not provided."
]
}
As suggested in the comments there is a space in the ngrok url posted to the workitem:
http://aa025317d1f2.ngrok.io /api/forge/callback/designautomation?id=76m1z2sw7uQi-jtAYzYvgA&outputFileName=20210314024133_output_revit_sample_file.rvt

Invalid HTTP_HOST header: 'api.binance.com'

I keep on getting this error the moment I enabled error messaging in Django. I research about it. This binance thingy is about bitcoin and it is not related to what I'm doing.
Is this an attack that's trying to check/access my Django Web app?
Invalid HTTP_HOST header: 'api.binance.com'. You may need to add 'api.binance.com' to ALLOWED_HOSTS.
Report at /api/v1/time
Invalid HTTP_HOST header: 'api.binance.com'. You may need to add 'api.binance.com' to ALLOWED_HOSTS.
Request Method: GET
I check the api.binance.com. It is like an api and it says "ok"
What's your thought about this?
This is issue just means that external device on the internet is trying to connect on Django however since the the URL " api.binance.com" is not on the allowed list on Django settings.
It is giving error only when you enable the debugging to sent on your email.

How to solve this "Caution: request is not finished yet in chrome"

I am facing an issue related to loading JSON data.
When I monitor JSON call on Developer Tools of Chrome, I get the following message in the network tab of Chrome Developer Tools.
Caution: request is not finished yet
Attaching a snip for reference:
It is caused by two-step response loading. If you are using some low-level API, make sure that you fetch not only headers, which arrive first, but also body content that comes later as a stream.
I had the same issue when using the fetch function in JavaScript. To solve it, make sure you call a method that reads the body of the response like json() or text():
// Sends request and loads only headers
fetch('/foo');
// Sends request, loads headers and then fetches the body as JSON
fetch('/foo').then(response => response.json());
In my case response headers were also loaded properly and I had a successful HTTP status code, but I was missing the body content and I had Caution: request is not finished yet inside Chrome Developer Tools.
consider removing all extensions and closing all the browser tabs
for me it helped - upon restart, all is well.
So strange
In my case, I needed to use response.text() instead of just using response. The usage of just response yields in "Caution: request is not finished yet"
fetch("API_URL_GOES_HERE", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
A tip here would be: Open Postman's Code snippet and view the actual JS Fetch that is happening.
I ran into this issue due to a programming error that caused an infinite loop in my JavaScript code.
Some time ago Chrome would point out that a script is stuck, but for some reason such a message did not show up in my Chrome. Instead, I found this error in the network tab.
Trying Firefox, it showed the error message "This page is slowing down Firefox. To speed up your browser, stop this page".
This helped me figure out that in my case the issue was not related to the request, but was actually caused by a script running forever.
Apparently, the infinite loop in JavaScript causes Chrome to not finalize the request or at least it does not update this display. I am not sure why Chrome would not show a more meaningful error message that a script is stuck.

API.ai Google Home Web Simulator error: "Bot isn't responding now. Try again soon." Error: Failed to parse SDKResponse from http_response

I restored an agent (working agent), using Restore from Zip option in API.ai. I tested the agent in API.ai and it worked successfully.
But when I try to integrate it with Google Home, and test it with the Google Home Web Simulator, I get the error:
"Bot isn't responding now. Try again soon."
Here is the Response Json:
"Failed to parse SDKResponse from http_response: 'HTTP/1.1 200 OK\r\nContent-Type: application/json;charset=UTF-8\r\nContent-Length: 230\r\nConnection: keep-alive\r\nDate: Tue, 09 May 2017 07:13:04 GMT\r\nServer: nginx/1.11.2\r\nAccess-Control-Allow-Credentials: true\r\nAssistant-Interaction-Error-Code: 1\r\nAssistant-Interaction-Error-Message: Empty speech response\r\nCache-control: no-cache=\"set-cookie\"\r\nSet-Cookie: AWSELB=9D5B4D210CCFFAF1BE1E0CD7C7E6FCBD7B46140CAAB35B563903DCE43FCC26342E3F89041AE3FE415E45579D21DA955B71D82B5CBB83188E876559AECB9AFBA466D1A80189;PATH=/\r\nX-Cache: Miss from cloudfront\r\nVia: 1.1 3212ba6c9a2d0009095ca19f00206ff3.cloudfront.net (CloudFront)\r\nX-Amz-Cf-Id: LUDwKPkUCwQJuK1elUUy3ZUZXTz-qcegNKGMUJv5Hb4k2a_ea2tRqg==\r\n\r\n{\"message\":\"Empty speech response\",\"apiResponse\":{\"id\":\"cd783d0c-11ab-438a-91ac-167f7998d678\",\"timestamp\":\"2017-05-09T07:13:04.382Z\",\"lang\":\"en\",\"result\":{},\"status\":{\"code\":200,\"errorType\":\"success\"},\"sessionId\":\"1494313984341\"}}'"
I would appreciate any help.
Thank you.
EDIT : SOLUTION
Reading the Response JSON, I noticed: Empty speech response. I rechecked my API.ai code and noticed that one of the Intents (in my case the Default Welcome Intent) was giving output Empty speech response. While on the console of API.ai this is not an issue, when you try linking to Google Home Web Simulator, it doesn't work. So in case you have a similar issue, maybe the first step of troubleshooting is figuring out which Intent is giving Empty speech response.
Hope this helps anyone else who faced a similar problem.

Magento Valid url redirects to 404

I am facing some issue with product url. Url seems to look fine but some times it's get redirected to 404 and the url-key value in address bar is getting replaced with 'null'.
I am not able to find any clue why its happening.
Can you any body suggest proper method to debug such issue?
Thank You.
This is basically URL rewrite issue. Check if the url rewrites are enabled: System> Configuration > Web > Search Engine Optimization > Use Web Server Rewrites.
And if the problem still persists do check your exception.log file
I'm aware this is a 2 year old post, but I had this issue today...
all previously valid product urls got a 404 error
after a lot of failed attempts of figuring out what was going on I asked someone to take a look, to which they replied: Err, What's wrong? ...
apparently everything was fine, but my own user's session/cookie had bad data, or something.
Removing the bad cookie fixed this.
I have no idea specifically what it was because I did not think of keeping a backup of the bad cookie/session data to investigate.
But I'm guessing it had something to do with my session's customer id or user id
Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[HY000]:
General error: 1032 Can't find record in 'report_viewed_product_index',
query was: INSERT INTO `report_viewed_product_index`