How to see request payload in jclouds? - jclouds

I'm trying to connect to an OpenStack system using jclouds and get the following error:
org.jclouds.rest.AuthorizationException: POST https://foo.bar.org:5000/v3/auth/tokens HTTP/1.1 -> HTTP/1.1 401 Unauthorized
at org.jclouds.openstack.nova.v2_0.handlers.NovaErrorHandler.handleError(NovaErrorHandler.java:93)
(This happens when I run val region = conn.getConfiguredRegions.iterator.next)
Is there a way for me to see the request payload to the POST request to help in diagnosing the issue further?

Setting jclouds.headers=DEBUG and jclouds.wire=DEBUG should reveal the request.

Related

Jmeter POST call with Form data and application/x-www-form-urlencoded

Need some help with Jmeter .
Environment: Apache Jmeter 5.0 , Java 1.8, Mac OS High Sierra 10.13.6
Problem outline:- Post call not getting 302 response with Location header(redirect) instead get 200 response without Location header
The problem here is in Jmeter but same works in Postman. In a Jmeter thread group I have cookie manager and couple of Get and Post calls. I set to save the cookie in user.properties file.
Scenario:- Login
1) first do GET ( call with some query parameters) / login endpoint will give response cookie and csrf-token with 200 then next
2) next do POST with form data ( in xxxform url encoded with csrf-token from get response ) + Cookie from get response from at / login endpoint should return 302 with token is the expected result but getting 200 instead with no redirection in Jmeter. In Postman able to get the desired results.
When the same is replicated in Jmeter with same setting as performed in Postman results are not as expected
Errors in Jmeter are:- 404 with location header missing or 200 with no Location response header
But not 302 with Location response header
With how many different combinations attempted.
Attached my sample TestPlans and Post request. Have also tried to place form data in Body instead in Parameters tab but have the same result.
Thanking in advance! Appreciate anyone who could share their thoughts and rescue from this current issue.

Quectel M95 HTTP POST timeout error

I'm trying to send a POST to a server but I always get the +CME ERROR: 3821. I know that this means "HTTP to read timeout". Then, I tried to change the server to another one, just to test, and then I get the same error 3821. My AT commands list is:
AT+CGATT=1
AT+QIFGCNT=0
AT+QICSGP=1,"zap.vivo.com.br"
AT+QIACT
AT+QILOCIP (IP OK!)
AT+QHTTPURL=38,30
CONNECT
http://www.posttestserver.com/post.php
OK
AT+QHTTPPOST=10,50,80
CONNECT
helloworld
OK
+CME ERROR: 3821
Does anyone know what is wrong?
I solved it by using directly
AT+QHTTPPOST=10,50
and not
AT+QHTTPPOST=10,50,10
hello even the issue is one year old i am writing answer if any one needs. In the source file of "ril_http.c" of Quectel modules, add delay of minimum 10ms in HTTP call back handler. it will solve the timeout error and will able to post it successfully.

Reddit API v1 - Forbidden by administrative rules

Hi I am trying to access my informations via authenticated request to the API.
I am working with Rails to do so, with no sucess, so I tried with Curl and got this:
Request:
curl -X GET -L "https://oauth.reddit.com/api/v1/me?access_token=BLURED_ACCESS_TOKEN" -A "webapp:integrationproject:v1.0 (by /u/Lupins)"
Response:
<html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>
I am trying to do the same with Rails with no success, this is what it looks like in Rails:
user_agent = 'WebApp:IntegrationProject:v1.0 (by /u/Lupins)'
response = RestClient.get "https://oauth.reddit.com/api/v1/me?access_token=#{auth}", user_agent: user_agent
I get the same forbidden error.
Can anyone help me to access this properly?
Solution:
Needed to send this string as header: Authorization: bearer BLURED_ACCESS_TOKEN

Amazon MWS Products API returns 401 error "Access denied"

I'm hopelessly stuck on trying to call Amazon MWS Products API. Particularly I'm trying to request this function
It requires building a pretty complicated request with a signature:
POST /Products/2011-10-01 HTTP/1.1
Content-Type: x-www-form-urlencoded
Host: mws.amazonservices.com
User-Agent: <Your User Agent Header>
AWSAccessKeyId=AKIAEXAMPLEFWR4TJ7ZQ
&Action=ListMatchingProducts
&MWSAuthToken=amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE
&MarketplaceId=ATVPDKIKX0DER
&Query=0439708184
&SellerId=A1IMEXAMPLEWRC
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2012-12-12T22%3A23%3A50Z
&Version=2011-10-01
&Signature=V%2BEXAMPLERT%2Baj%2Fxwqo7y3PIifMFHeqFlNYW0EXAMPLEA%3D
I build this query with the help of this little library:
So my final url string looks like this:
https://mws.amazonservices.com/Products/2011-10-01?AWSAccessKeyId=<MY_ACCESS_KEY>&Action=ListMatchingProducts&MarketplaceId=A1PA6795UKMFR9&Query=0439708184&SellerId=<SELLER_ID>&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-04-19T16%3A50%3A13Z&Version=2011-10-01&Signature=mZt3OhM14gwLdsQ%2Bhxz5UFMzr7m2U36DvZ7RG3dcsTI%3D
And it seems that the url string is built correctly. I think so because if a parameter is missing or incorrect the API returns 400 error with explanation that this parameter is invalid. The same applies for the signature. If signature is incorrect the API returns error which clearly states that the signature is invalid. So, again, I think that the url must be ok. However the API returns 401 error and a html page which looks like this:
<?xml version="1.0"?>
<ErrorResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<Error>
<Type>Sender</Type>
<Code>AccessDenied</Code>
<Message>Access denied</Message>
</Error>
<RequestID>7b12e3c8-7b1a-4b6e-b7ba-15ec8c4e0968</RequestID>
</ErrorResponse>
Access denied. And I have no idea why. I've spent several hours already trying to figure out what's wrong. Can anyone help me?
The reason for the problem was that I was calling American url https://mws.amazonservices.com instead of European one https://mws-eu.amazonservices.com. It would be really nice if Amazon response gave more context about the error than simply Access denied

Server App on Heroku is not accessibe

Hi we have a Ruby on Rails server application on Heroku, but when I send a post request to it, I always get a 400 Bad Request response. I have searched other 400 errors, but none are related to our issue. The HTTP response that we receive looks like this below:
HTTP/1.1 400 Bad Request
Server: Cowboy
Date: Fri, 14 Aug 2015 21:55:25 GMT
Content-Length: 0
The post request that I am sending looks like this below:
POST http://ourapp.herokuapp.com/api/v1/requests HTTP/1.0
Accept-Language: en-us
Accept: text/plain
Content-Type: application/x-www-form-urlencoded
Content-Length: 38
Connection: Close
request=600&key=&newKey=danasecretkey&
Sorry, I had to put blank lines after each header or it would all show up on one line.
If I create an HTML form to send the data, there is no issue. It's when I then try to send the same request from our file server, that I get the errors. I tried using a preflight request with all of the correct request headings, but received the same 400 Bad Request error.
Does anyone have any suggestions as to what I might be doing wrong?
Well, just guessing from what you've said:
request=600&key=&newKey=danasecretkey&
It's likely that you have something like params.require(:key) in your controller. And your request is missing that parameter.
Rails will respond with 400 status in case you missed some require'd params.
What fixed it was switching from HTTP1.0 to HTTP1.1, adding the host header and changing the uri.
The logs didn't tell us anything, and the params were ok. The problem was not fully grasping the HTTP header requirements.

Resources