Couldn't send 'multipart/form-data;boundary=' request through Postman - postman

I am trying to publish a workbook through rest api to the tableau server.
This is the below curl request which I am importing in the postman:
curl "https://MY_SERVER/api/3.4/sites/site-id/workbooks" -X POST -H "X-Tableau-Auth:credentials token" -H "Content-Type: multipart/mixed;" -F "request_payload=#publish-workbook.xml" -F "tableau_workbook=#MY_WORKBOOK.twbx"
But it is throwing this below error:
<?xml version='1.0' encoding='UTF-8'?>
<tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api https://help.tableau.com/samples/en-us/rest_api/ts-api_3_18.xsd">
<error code="406000">
<summary>Bad Request</summary>
<detail>Content type 'multipart/form-data;boundary=--------------------------313748027746018569295475' not supported</detail>
</error>
</tsResponse>
Also we are trying to publish datasource using postman. But same type of error is coming. Kindly help regarding this issue.
I am trying to hit this below curl from postman:
curl "https://MY_SERVER/api/3.4/sites/site-id/workbooks" -X POST -H "X-Tableau-Auth:credentials token" -H "Content-Type: multipart/mixed;" -F "request_payload=#publish-workbook.xml" -F "tableau_workbook=#MY_WORKBOOK.twbx"
I am expecting to publish the workbook in tableau server.
References:
https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#publish_data_source
https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_publish.htm

Related

Receiving Invalid Grant Type Error Received From AWS Cognito When Supply Auth Code : How do I get Id and access tokens for testing?

I am unable to successfully acquire an id token/access token from my AWS cognito user pool when I supply an auth code. I have written a shell script (see below), and receive invalid_grant back from the server.
I have encoded the base64 Authorization Basic header for client_id:client_secret generated with python as:
import base64
encode='my_client_id_string:my_client_secret_string'
base64.b64encode(encode)
#!/usr/bin/env sh
curl --location --request POST 'https://<domain>.auth.us-east-2.amazoncognito.com/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic <base64 encode string client_id:client_secret>' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'client_id=<client_id from app settings' \
--data-urlencode 'code=<code received from redirect url to my localhost app endpoint>' \
--data-urlencode 'redirect_uri=http://localhost:8000/my_redirect'
Any ideas?
Solved it!
The problem was caused by an invalid client id. I had supplied a typo for the client id value!

Google cloudstorage returns 404 Not Found when trying to delete from bucket

I am trying to delete a file (video) from Google Cloud Storage via the cloudstorage api but although the file exists I'm getting the following error:
cloudstorage.delete('/catchamove-video/products/6411421952770048.mp4')
*** NotFoundError: Expect status [204] from Google Storage. But got status 404.
Path: '/catchamove-video/products/6411421952770048.mp4'.
Request headers: None.
Response headers: {'transfer-encoding': 'chunked', 'date': 'Sun, 07 May 2017 12:31:47 GMT', 'server': 'Development/2.0'}.
Body: ''.
Extra info: None.
Both the bucket and file are present on the console.
I am facing the same problem: getting 404 when delete a folder via REST API.
After some tests, I figured out how delete folder of GCP storage -
Have to delete all files (objects) in the folder, files in sub-folders and sub-folders and folder. Be noticed that when deleting empty folder, you may still get "404 Not Found"(normally gets 204), just ignore it and the empty folder will be actually deleted.
Examples:
curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2Ffile1
curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2Ffile2
curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2F #May get 204 or 404 response code
curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2F #May get 204 or 404 response code
NOTE: "%2F" in the URL is actually "/" character

Uploading to Amazon S3 using signed S3 url in Grails

Curl successfully uploads the file to S3 using a signed url:
curl -v -k -X PUT \
-H "x-amz-server-side-encryption: AES256" \
-H "Content-Type: application/pdf" \
-T "__tests__/resources/test.pdf" \
"http://mybucket.s3.amazonaws.com/test.pdf?AWSAccessKeyId=IDKEY&Expires=1489458783&Signature=SIGNATURE
I've tried replicating this in Grails using the REST client plugin:
String url = "http://mybucket.s3.amazonaws.com/test.pdf?AWSAccessKeyId=IDKEY&Expires=1489458783&Signature=SIGNATURE"
RestResponse resp = rest.put(url){
header "x-amz-server-side-encryption", "AES256"
header "Content-Type", "application/pdf"
body pdf
}
But Amazon rejects the upload, saying the arguments are incorrect...probably due to the pdf being sent as a "body" parameter. Any ideas?
Instead of using a rest client to upload it would be simpler to use the AWS Java SDK in your Grails app.
See an example here of using a pre-signed url to upload http://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObjectJavaSDK.html

Error while generating authentication token in Django Rest Framework

I have created an endpoint localhost:8000/getauthtoken to generate the authentication token.
The curl command that i am using to get the authentication token is:
curl --request POST --url localhost:8000/getauthtoken --header 'content-type: application/json' --data '{"username":"admin", "password":"admin123"}'
But i am getting
{"password":["This field is required."],"username":["This field is required."]}
But in the command i am passing both username and password
As per the DRF documentation http://www.django-rest-framework.org/api-guide/authentication/ this is the correct way.
Use httpie (available on pypi)
Then follow this on terminal:
Http post your_ip:your_port/your_authresource/ username='' password=''
Or you can try that in Curl in right way:
curl -X POST http://localhost:8000/api-token-auth/ -d "password=aaaaa&username=user"

Django-rest-auth basic authorization error {"password":["(This field is required"]}

I i am new to django-rest-auth and apis.
Its the first time i build a rest auth and i am not very familiar with Authorization headers and Content Types.
I am trying to understand why when i try to authenticate a user in /login/ with Basic Authorization like this:
curl -X POST -H "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=" 'https://myurl.com/rest-auth/login/' --insecure
i got this error message:
{"password":["(This field is required"]}
When passing the username and password in the body like this:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'username=myuser&password=mypassword' 'https://myurl.com/rest-auth/login/' --insecure
I got the key:
{"key":"b5c0f3a9c7b2fc2f58a74b25f816e2968c64712f"}
Why this is happening?
I also wonder why when trying the same in /user/ it didn't throw me any error and give me my user model serialized
curl -X GET -H "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=" -H "Cache-Control: no-cache" 'https://myurl.com/rest-auth/user/' --insecure
The only difference i can understand is that in /login i am using POST and in /user/ is GET
Can anybody explain this to me?
Thanks for reading!
The '/auth/login/' endpoint is specifically for getting an authentication token to use with token authentication on the rest of the app. It doesn't itself support any authentication methods. The second curl command uses the correct method. the third curl command works because you are using an endpoint which does support Basic Authentication (you can could also use the token you got in the second call).
pls refer
Inet Mode Example (unprivileged user with AltAuth)
$ echo -e "GET http://localhost/slurm/v1/diag HTTP/1.1\r\nAccept: */*\r\n" |
slurmrestd -f etc/slurm.token.conf
● slurmrestd: operations_router: /slurm/v1/diag for pipe:[1052487]
● HTTP/1.1 200 OK
● Content-Length: 973
● {
● "parts_packedg": 1,
● "req_timeg": 1568051342,
● "req_time_startg": 1568050812,
● "server_thread_count": 3,
… JSON continues ...