Hello Everyone, I am attempting to receive a response from an Rakuten API. Not sure what I am missing because I am getting this response:
{ “fault”: { “code”: “403”, “type”: “Status report”, “message”: “Runtime Error”, “description”: “No matching resource found in the API for the given request” }
{“grant_type”:“password”,“password”:“jj”,“scope”:342511,“username”:“jj”}
Code -
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"encoding/json"
)
type SearchParams struct {
Keywords string `json:"keywords"`
}
type SearchRequest struct {
RegionID string `json:"region"`
UserID string `json:"uid"`
}
//output API response
type ItemInfo struct {
ASIN string `json:"asin,omitempty"`
PartnerID string `json:"pid,omitempty"`
DetailPageURL string `json:"detailPageURL,omitempty"`
}
type Price struct {
CurrencyCode string `json:"currencyCode,omitempty"`
Amount float32 `json:"amount,omitempty"`
}
type PointPrice struct {
AMEX float32 `json:"AMEX,omitempty"`
CUR float32 `json:"CUR,omitempty"`
ThankYou float32 `json:"ThankYou,omitempty"`
Discover float32 `json:"Discover,omitempty"`
}
type ItemListings struct {
ItemList []ItemInfo `json:"items"`
CashLow string `json:"cashlow,omitempty"`
}
func main() {
client := &http.Client{
}
response, err := client.Get("https://api.rakutenmarketing.com/token")
req, err := http.NewRequest("GET", "https://api.rakutenmarketing.com/token", nil)
req.Header.Add("Authorization", `"Basic djl6eUp5YUNZX2tZODdOaFRhSmVOZnFqME93YTpGZzJxWHRhNTlvXzUyZ0VNNDFiVThaZjhQa3Nh"`)
//resp, err := client.Do(req)
if err != nil {
fmt.Print(err.Error())
os.Exit(1)
}
payload := map[string]interface{}{"grant_type": "password","username":"jj","password":"pp1234","scope":342511}
byts, _ := json.Marshal(payload)
fmt.Println(string(byts))
responseData, err := ioutil.ReadAll(response.Body)
if err != nil {
log.Fatal(err)
}
var responseObject SearchParams
json.Unmarshal(responseData, &responseObject)
fmt.Println(string(responseData))
}
---------------------------side note - this is the guide for the parameters from Rakuten API site
Configure your application or favorite Web Service client (e.g. Advanced Rest Client) to
make the following request:
a. URL: https://api.rakutenmarketing.com/token
b. HTTP Verb: POST
c. Headers:
i. Authorization:
d. Payload:
i. grant_type=password
ii. username=
iii. password=
iv. scope=
------------------------Any Help\assistance\lead would be much appereciated (:
Jenny