duancan1950 2016-11-17 09:41
浏览 175
已采纳

如何克服ResourceNotFoundException:Go lang中找不到请求的资源错误?

I am a beginner in Go lang and I am trying to establish a connection between Go lang and Dynamodb using AWS and insert data in dynamodb using an API written in Go lang. Any help would be appreciated.

Below is the code of what I am trying to do:

package main
import "fmt"    
import (  
        "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/aws/credentials"
    "github.com/aws/aws-sdk-go/service/dynamodb"
        "github.com/user/dynamo_connect/data"
    )
func database_init() {
    
        var testCredentials = credentials.NewStaticCredentials("Access_key", "secret_key", "")
    sess, err := session.NewSession()
    svc := dynamodb.New(sess, &aws.Config{
        Region: aws.String("us-east-1"),
        Credentials: testCredentials,
    })
    resp, err := data.UploadForumData(svc)

    if err != nil {
        fmt.Println("An error occurred while writing to the Employee table")
        fmt.Println(err.Error())
    }
    fmt.Println(resp)

    }
func main() {
    database_init()
}

package data

import "github.com/aws/aws-sdk-go/service/dynamodb"
import "github.com/aws/aws-sdk-go/aws"

func UploadForumData(svc *dynamodb.DynamoDB) (*dynamodb.BatchWriteItemOutput, error) {
    params := &dynamodb.BatchWriteItemInput{
        RequestItems: map[string][]*dynamodb.WriteRequest{
            "employee": {
                &dynamodb.WriteRequest{
                    PutRequest: &dynamodb.PutRequest{
                        Item: map[string]*dynamodb.AttributeValue{
                            "emp_id": {
                                S: aws.String("2"),
                            },
                            "address": {
                                S: aws.String("Wing Apartment"),
                            },
                            "emp_name": {
                                S: aws.String("Kaushal"),
                            },
                        },
                    },
                },
                
            },
        },
    }

    return svc.BatchWriteItem(params)
}

And this is the error which I am getting:

An error occurred while writing to the Employee table
ResourceNotFoundException: Requested resource not found
    status code: 400, request id: VIMB3ATCI6KPSJF1OOH2Q4VLKNVV4KQNSO5AEMVJF66Q9ASUAAJG
{

}

Can anyone help?

</div>
  • 写回答

1条回答 默认 最新

  • douwudie8060 2016-11-19 11:04
    关注

    Actually, there is issue with my database connectivity.The region name which I have entered is incorrect. I have rechecked that using aws configure command and got it working.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大