상품 등록 오류 #1922
Unanswered
Reichlinstrasse
asked this question in
묻고 답하기
상품 등록 오류
#1922
Replies: 1 comment
|
안녕하세요 커머스API 권현철입니다. 말씀하신 내용에 대해 답변 드리겠습니다. '상품 등록API'의 요청문 중
하단의 예시와 같이 {
"originProduct": {
.....
},
"smartstoreChannelProduct": {
.....
}
}
감사합니다. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
파이썬 스트립트
import requests
import json
import http.client
발급된 액세스 토큰을 여기에 입력
access_token = "xxxxxxx" # 실제 발급받은 토큰으로 교체
scraped_product_data.json 파일 불러오기
with open('scraped_product_data.json', 'r', encoding='utf-8') as file:
scraped_product_data = json.load(file)
payload 구성
payload = {
"originProduct": {
"statusType": "SALE", # 올바른 Enum 값 설정
"saleType": "NEW",
"leafCategoryId": "50013421", # 실제 카테고리 ID로 교체
"name": scraped_product_data["name"],
"detailContent": scraped_product_data["about_this_item"] + "\n\n" + scraped_product_data["important_information"],
"images": {
"representativeImage": {"url": scraped_product_data["image_urls"][0]}, # 첫 번째 이미지를 대표 이미지로 사용
},
"salePrice": int(scraped_product_data["price"] * 1000), # 네이버 커머스 API는 가격을 원 단위로 입력
"stockQuantity": 100, # 재고 수량 설정
"deliveryInfo": {
"deliveryType": "DELIVERY",
"deliveryAttributeType": "NORMAL",
"deliveryCompany": "CHI", # 배송업체 코드로 교체
"deliveryBundleGroupUsable": False,
"deliveryFee": {
"deliveryFeeType": "FREE", # 무료 배송으로 설정
"baseFee": 0, # 기본 배송비 0원
"deliveryFeePayType": "PREPAID", # 선불로 설정
"deliveryFeeByArea": {
"deliveryAreaType": "AREA_3", # 모든 지역에 대해 적용
"area2extraFee": 0, # 추가 배송비 0원
"area3extraFee": 0 # 추가 배송비 0원
},
"differentialFeeByArea": None # 차등 배송비 설정 없음
},
"claimDeliveryInfo": {
"returnDeliveryCompanyPriorityType": "PRIMARY", # 우선 반품 배송업체 설정 (예: 한진택배)
"returnDeliveryFee": 15000, # 반품 배송비 15,000원
"exchangeDeliveryFee": 30000, # 교환 배송비 30,000원
"shippingAddressId": None, # 주소 ID 없음, 기본 주소 사용
"returnAddressId": None, # 주소 ID 없음, 기본 주소 사용
"freeReturnInsuranceYn": False # 무료 반품 보험 사용 안함
},
"installationFee": False # 설치비 없음
},
"detailAttribute": {
"naverShoppingSearchInfo": {
"modelName": "상세페이지 참조", # 필요 시 수정
"manufacturerName": scraped_product_data["brand"],
"brandName": scraped_product_data["brand"]
},
"afterServiceInfo": {
"afterServiceTelephoneNumber": "xxxxx", # A/S 전화번호 수정
"afterServiceGuideContent": "상세페이지 참조" # A/S 안내 내용 수정
},
"originAreaInfo": {
"originAreaCode": "0204000", # 원산지 코드: 미국
"content": "미국" # 원산지 추가 설명
},
# 셀러 코드 정보 제거
"optionInfo": {
"simpleOptionSortType": "CREATE",
"optionSimple": [],
"optionCustom": [],
"optionCombinationSortType": "CREATE",
"optionCombinationGroupNames": None,
"optionCombinations": None,
"useStockManagement": False # 재고 관리 안 함
},
"taxType": "TAX", # 과세 상품
"certificationTargetExcludeContent": {
"childCertifiedProductExclusionYn": True, # 아동 인증 대상에서 제외
"kcCertifiedProductExclusionYn": "TRUE" # KC 인증 정보 없음
},
"minorPurchasable": True, # 미성년자 구매 가능
"productInfoProvidedNotice": {
"productInfoProvidedNoticeType": "ETC",
"etc": {
"returnCostReason": "상세페이지 참조",
"noRefundReason": "상세페이지 참조",
"qualityAssuranceStandard": "상세페이지 참조",
"compensationProcedure": "상세페이지 참조",
"troubleShootingContents": "상세페이지 참조",
"itemName": "상세페이지 참조", # 필요 시 수정
"modelName": "상세페이지 참조", # 필요 시 수정
"certificateDetails": "상세페이지 참조", # 필요 시 수정
"manufacturer": scraped_product_data["brand"],
"afterServiceDirector": "상세페이지 참조" # 필요 시 수정
}
}
# productAttributes 필드 제거
},
"customerBenefit": {
# 구매 혜택 관련 항목 모두 제거
"freeInterestPolicy": {"value": 3}, # 무이자 할부 3개월 설정
# 사은품 정책, 다중 구매 할인 정책 모두 제거
},
"smartstoreChannelProduct": {
"storeKeepExclusiveProduct": False,
"naverShoppingRegistration": True, # Boolean으로 설정
"channelProductDisplayStatusType": "ON"
}
}
}
헤더 설정
headers = {
'Authorization': f"Bearer {access_token}",
'Content-Type': "application/json"
}
POST 요청 보내기
conn = http.client.HTTPSConnection("api.commerce.naver.com")
conn.request("POST", "/external/v2/products", json.dumps(payload), headers)
응답 받기
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
오류
"c:/Users/jyj26/OneDrive/Desktop/VS FILE/SS upload.py"
{"code":"BAD_REQUEST","message":"입력한 데이터가 유효하지 않습니다.","invalidInputs":[{"name":"smartstoreChannelProduct","type":"NotNull","message":"데이터를 입력해 주세요."}],"timestamp":"2024-08-30T18:54:55.763+09:00"}
안녕하세요 위에 처럼 만들었는데 smartstoreChannelProduct 부분에서 계속 오류가 뜹니다
},
"smartstoreChannelProduct": {
"channelProductName": scraped_product_data["name"], # 채널 상품 전용 상품명
"bbsSeq": 0, # 콘텐츠 게시글 일련번호 (이 값이 없으면 기본값 0을 사용)
"storeKeepExclusiveProduct": False, # 알림받기 동의 회원 전용 상품 여부 (기본값 False)
"naverShoppingRegistration": True, # 네이버쇼핑 등록 여부 (필수 필드)
"channelProductDisplayStatusType": "ON" # 전시 상태: ON, WAIT, SUSPENSION 중 하나 (필수 필드)
All reactions