I am trying to get a response from Geocode API for an address(company name,street,zip,country)to fill latitude and longitude.My API request is:
https://maps.googleapis.com/maps/api/geocode/xml?address=BULTORFER DE AGUSTÍN JURADO,AV. PIO X 102+5730+Rio Tercero+AR&sensor=true&key=****************
Company Name : BULTORFER DE AGUSTÍN JURADO
Street : AV. PIO X #102
ZIP :5730
Town :Rio Tercero
Country : AR
The response for the above API GET request is:
<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>REQUEST_DENIED</status>
<error_message>You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account</error_message>
</GeocodeResponse>
But if I removed # from the Street : AV. PIO X 102 the API works fine and give proper result.How to solve this issue?
You need to url encode '#' into '%23'. More info here: https://en.wikipedia.org/wiki/Percent-encoding
Related
I am trying to create a category in moodle making api call from postman
API Endpoint: http://localhost/MyMoodle/webservice/rest/server.php
Method: POST
Payload: Selected x-www-form-urlencoded
wstoken:<token>
wsfunction:core_course_create_categories
moodlewsrestfomat:json
categories[0][name]:Custom Cat 1
categories[0][parent]:0
categories[0][idnumber]:1
categories[0][description]:CustomCatdescription
getting below error
<?xml version="1.0" encoding="UTF-8" ?>
<EXCEPTION class="invalid_parameter_exception">
<ERRORCODE>invalidparameter</ERRORCODE>
<MESSAGE>Invalid parameter value detected</MESSAGE>
</EXCEPTION>
Based on the error and the test parameters, I'd guess it's one of these issues:
Postman isn't encoding the spaces, and Moodle doesn't like that. Try replacing the spaces in your category name with %20
The idnumber is not unique. Check that a category with that idnumber doesn't already exist.
Also, I just wanted to note that you can also test the Moodle API directly in your browser. This can be a good way to make sure there's not an issue with any of your credentials or permissions. Just navigate to a url like this:
http://localhost/MyMoodle/webservice/rest/server.php?moodlewsrestformat=json&wstoken=<token>&wsfunction=core_course_create_categories&categories[0][name]=Custom%20Cat%201&categories[0][parent]=0&categories[0][idnumber]=1&categories[0][description]=CustomCatdescription
While accessing the China Map Rest API's in postman using the app_id and app_code generated (Free Trial Plan), below response if receieved.
URL: https://2.base.maps.hereapi.cn/maptile/2.1/maptile/newest/normal.day/13/6744/3104/256/png8?app_id=<>&app_code=<>
{
"error": "Unauthorized",
"error_description": "This is not a valid app_id and app_code pair. Please verify that the values are not swapped between the app_id and app_code and the values provisioned by HERE (either by your customer representative or via http://developer.here.com/myapps) were copied correctly into the request."
}
We are blocked with testing China Map . Please let me know what other information is required to be provide to analyse the issue.
Thank you
Regards
Sri Vidhya
I have an issue when including the special characters such as "#" in Amazon Listing API. For example, the sku, HP-2DP98AA#ABC-200621 will be updating the quantity at 20. However, Amazon API responses InvalidSignature
I did apply the encoding for the SKU before submitting the request to Amazon, but it is failed all the time. Any idea?
the AWS documents selling-partner-api-docs Rest API about how to patch the items URL is PATCH /listings/2020-09-01/items/{sellerId}/{sku}. This means that sku need to add in URL which contains "#" like this.
/listings/2020-09-01/items/{your sellerId}/HP-2DP98AA#ABC-200621
This request URL would be cause the exception or InvalidSignature from AWS , because "#" in URL need to encode "#" to "%23" such as below:
/listings/2020-09-01/items/{your sellerId}/HP-2DP98AA%23ABC-200621
Also, need to add sellerId, marketplaceIds, and sku parameters as well.
Additionally, AWS4 Canonical Request is like below:
AWS4 Canonical Request: '"PATCH
/listings/2020-09-01/items/{your sellerId}/HP-2DP98AA%2523ABC-200621
marketplaceIds={your marketplaceIds}&sellerId={your sellerId}&sku=HP-2DP98AA%23ABC-200621
content-type:application/json; charset=utf-8
host:sellingpartnerapi-na.amazon.com
x-amz-access-token:Atza|...
x-amz-date:20210831T190152Z
x-amz-security-token:Fwo...
content-type;host;x-amz-access-token;x-amz-date;x-amz-security-token
d1809d68......"
I want to use the provided slack web API https://api.slack.com/web#basics to get some messages out of a channel. I looked at https://api.slack.com/methods/channels.history & used the Request API to call the service.
payload = {'token': 'XXXXXXXXXXXX', 'channel': '#scanbot' , 'count' : '10'}
r = requests.get('https://slack.com/api/channels.history', params=payload)
print r.status_code
print r.text
But i am getting the error:
200
{"ok":false,"error":"channel_not_found"}
I am pretty sure the channel exists and I am providing correct API key. Can someone point me at the correct directions please?
You need to pass the channel ID as the argument to the channels.history endpoint.
The channel IDs may be fetched by checking the channels.list endpoint.
See for example the source of the Slacker package.
The JSON-formatted response may be parsed with:
import json
data = json.loads(r.text)
print data
I am trying to send mails with attachment by using Amazon SES
HttpRequest httpReq = new HttpRequest();
httpReq.setMethod('POST');
httpReq.setEndpoint('https://email.us-east-1.amazonaws.com');
Blob bsig = Crypto.generateMac('HmacSHA256', Blob.valueOf(awsFormattedNow), Blob.valueOf(secret));
httpReq.setHeader('X-Amzn-Authorization','AWS3-HTTPS AWSAccessKeyId='+key+', Algorithm=HmacSHA256, Signature='+EncodingUtil.base64Encode(bsig));
httpReq.setHeader('Date',awsFormattedNow);
httpReq.setHeader('From','sample#gmail.com');
httpReq.setHeader('To','sample#gmail.com');
httpReq.setHeader('Subject','Hello');
httpReq.setHeader('Accept-Language','en-US');
httpReq.setHeader('Content-Language','en-US');
httpReq.setHeader('Content-Type','multipart/mixed;boundary=\"_003_97DCB304C5294779BEBCFC8357FCC4D2\"');
httpReq.setHeader('MIME-Version','1.0');
// httpReq.setHeader('Action','SendRawEmail');
String email = 'Action=SendRawEmail';
email += '--_003_97DCB304C5294779BEBCFC8357FCC4D2 \n Content-Type: text/plain; charset="us-ascii" \n Content-Transfer-Encoding: quoted-printable \n';
email +='Hi Andrew. Here are the customer service names and telephone numbers I promised you.';
httpReq.setBody(email);
System.debug(httpReq.getBody());
Http http = new Http();
HttpResponse response = http.send(httpReq);
I am getting error like
<AccessDeniedException>
<Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>
Kindly please help me where i am doing wrong .Thanks in advance
Take another look at the documentation. There are several issues with your code.
SES expects an HTTP POST with all of the parameters strung together consistent with application/x-www-form-urlencoded POST requests.
Your HTTP request needs to be Content-type: application/x-www-form-urlencoded, not multipart/mixed... -- that's part of the raw message you're trying to send.
You are mixing up things that should be in the body, and setting HTTP request headers, instead. For example, these are also incorrect:
httpReq.setHeader('From','sample#gmail.com');
httpReq.setHeader('To','sample#gmail.com');
httpReq.setHeader('Subject','Hello');
These should go in the request body, not in the HTTP request headers. Also, the values are urlencoded. From the example code:
Action=SendEmail
&Source=user%40example.com
&Destination.ToAddresses.member.1=allan%40example.com
The line breaks were added for clarity.
Your interests might be best served by trying to successfully send a simple e-mail, first, and then later attempting to modify your code to support attachments, because you have numerous errors that will need to be corrected before this code will work properly.
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/query-interface-requests.html
http://docs.aws.amazon.com/ses/latest/APIReference/API_SendRawEmail.html