Google Civic API: 400 Bad Request [duplicate] - vb.net

This question already has answers here:
400 BAD request HTTP error code meaning?
(10 answers)
Closed 3 years ago.
This is my first time using an API, and i'm trying to figure out what exactly i'm doing wrong here. I'm trying to do the simple tutorial as seen here
I'm using Vb.net and the code i'm using is...
Public Sub New()
Dim webClient As New System.Net.WebClient
Dim iplookup As String = webClient.DownloadString("https://www.googleapis.com/civicinfo/v2/elections?key=<AIzaoKpBLK6uOqCJovCHmbHWYavDxx4cA-3_v8>")
console.WriteLine(iplookup)
End Sub
And I keep getting a 400 bad request error and i'm not sure what I'm doing wrong. Any and all help is much appreciated. As I said, this is my first time using an API so please dumb it down if you could. Also, I changed a few characters in my key to post this.

Accessing the link you used on the code, you get more details about the error, specifically this:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
Meaning you API Key is invalid. First of all, I surely don't think the "<" and ">" are part of the key, so try removing that first. Then, you should check you account to see if you are using the correct key. If it still doesn't work, check restrictions.
Go to your Google API Console, on the left side click on Credentials, and there should be your Key. If it's not, create one. Check your restrictions to make sure you can access it, then click the little copy button on the right side to make sure your are not copying it wrong. Replace the APIKEYHERE and nothing else on the following link with your key, making sure to not add anything else, and try to access it in your browser. If you have no setting in your API you should get an Error 403, meaning you didn't configure the access: googleapis.com/civicinfo/v2/elections?key=APIKEYHERE

Related

postman giving 400 bad request when i use global varibales how to solve this

when i use normal json body postman gives me 201 created response but when i am using global variable postman giving me 400 bad request
Variables still need to be used in proper JSON format therefore you should be putting your strings in quotes:
{
"email": "{{email}}",
"password" : "{{password}}",
"confirmpassword" : "{{confirmpassword}}"
}
See https://learning.postman.com/docs/sending-requests/variables/
Side note: please provide actual "happy path" (when it worked) as well as your errors. Text instead of images is good too to help people try to reproduce your errors without a lot of typing

Unable to create in google spreadsheets

I was trying google APIs to create a new sheet but I am unable to achieve the goal
the error I am getting is
Invalid spreadsheet. spreadsheet: This user did not create this id.
so I thought I am doing something wrong did some research I got this link (https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/create) and tried it here (Try it! button) it gives the same error
{
"error": {
"code": 400,
"message": "Invalid spreadsheet.spreadsheetId: This user did not create this id.",
"status": "INVALID_ARGUMENT"
}
}
What am I doing wrong?
Just performing the following request will create a spreadsheet:
POST https://sheets.googleapis.com/v4/spreadsheets
No need to pass something in the body. The documentation is a bit confusing on that point as it says you should send an instance of Spreadsheet in the request body. But you don't have to.

Zapier basic auth pass blank data

I have been trying to create an app in Zapier for one of my project. On the very first step, I am doing Authentication where I choose "Basic Auth" method. I have set API URL along with details, however cannot see the expected result and seeing error in my API return value. After debugging, I found that API doesn't get the value I pass thru the Zapier. I have checked the same API in postman and it works, however it only doesn't work thru the Zapier.
Below is even more detail how I proceed, what is expected result and what I am getting:
Process we're following
We have created an App
We went to Authentication step, there we have selected “Basic Auth” option
Under the Basic Auth, we have configure with setting end point and method is “Post”
We have set our field names as Key and as value we have set “{{bundle.authData.password}” and “{{bundle.authData.username}}” in order to field mapping
Then came to Step 2 to test the authentication
Under the “Test Setup”, we have connected the current Zapier account and clicked on “Test Authentication”
This process doesn’t post any value in parameters. Hope I could explain the issue, please help us to find where we’re going wrong.
Expected Result
{
"data": {
"first_name": "Dhaval",
"last_name": "Parekh",
"email_address": "dhaval.php#gmail.com",
"phone_no": "1234567890",
"user_id": "7oiA****",
"token_id": "zNkzT***"
},
"resend_verification_link": false,
"status": true,
"message": "You have successfully Logged in!!"
}
Actual Result
{
"resend_verification_link": false,
"status": false,
"message": "The password must contain a minimum of one lower case character. one upper case character, one digit"
}
What I understand after spending too much time, is it doesn't send the data with post method and hence I'm getting this issue. While it works fine with the Get Method. So, should I consider that Basic Auth will only with work with "Get" method in Zapier? Or I'm missing any piece to include here?
Please let me know what is missing? Or even I'm going thru the wrong root. I want to create an app in Zapier to allow other apps to connect.

Question about testIamPermissions method in Billing API

I'm trying to use cloudbilling.billingAccounts.testIamPermissions in the APIs Explorer, but I get an error.
API URL
https://developers.google.com/apis-explorer/?hl=ko#p/cloudbilling/v1/cloudbilling.billingAccounts.testIamPermissions?resource=billingAccounts%252F01183E-6A3E97-BE2C7A&resource=%257B%250A%257D&_h=1&
Error Result
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
The error message appears as 'Request contains an invalid argument', so the value entered in resource seems to be incorrect.
I entered billingAccounts / {billingAccountID} for resource, but I do not know why I get an error.
{billingAccountID} has entered the billing account ID you are using.
What value should be put in the resource?
You need to use your full ID "billingAccounts/012345-567890-ABCDEF`" as an string. Also avoid to share your private information for security reasons use examples instead.
Confirm that the other options of the API works for you.

"integrationuser" is not an Active user in KissFlow

I am using kissflow API to attach file but I am getting this error
{
"error": "ValidationError The user integrationuser#xxxxxxx is not an
Active user" }
I am using this url with data {Name:'xxxxx','Url':'xxxxxx'} as suggested in Doc
https://sxxxxxxxxx.appspot.com/api/1/Print Quotation/Sxxxxxx9/attachment/create
I already created request for this with this url
http://sxxxxxxxxx8.appspot.com/api/1/PrintQuotation/create
And got success result with id and subject
{
.......
Id": "d442c98a-bca2-11e8-9ac6-c7734a25d32a",
"Subject": "Request from integrationuser#ap9d9afe30_96bd_11e8_a251_0e8f5e2360a0"
}
Please help me to understand why this error comes.
Note : I am using test account.
And there is no such user with name integrationuser in Users
I got the same error, in my case im using a real account.
SOLUTION 1 :
Create a valid account for use in integrations e.g. integration#companydomain.com
Add the header "email_id" with the email of this user "integration#companydomain.com"
It works for me with a valid account.
However i need to pay by a license for it =P.
I'm talking with support for a better solution using default integrationuser, i will post here the answer from support for clarify this situation.
You can see this solution on documentation here :
https://help.kissflow.com/tips-and-tricks/api-documentation/rest-api-points