Gostaria de saber se está com algum problema no API de gift cards, para criar um novo Gift Card via post.

Do dia 04/05/2018 em diante, todas as nossas chamadas na API vtex do giftcard, não tiveram sucesso.

Nada foi alterado em nossa parte. O Erro começou no dia 04/05/2018 e ocorre com qualquer GiftCard

Sugue abaixo os dados da chamada e em seguida a mensagem de erro:

URL: https://nomedaminhaloja.vtexcommercestable.com.br/api/gift-card-system/pvt/giftCards

Headers: x-vtex-api-appKey :(meuappkey),

x-vtex-api-appToken: (meuapptoken)

Request:

{

"customerId": "CustomerId",

"ownerId": "153639",

"cardName": "153639",

"caption": "Vale Trocas",

"expiringDate": "2018-11-06 00:00:00",

"multipleCredits ": false,

"multipleRedemptions ": true,

"restrictedToOwner ": true

}

E após a chamada, retorna essa mensagem de erro:

Erro: Object reference not set to an instance of an object.

Abra um chamado neste caso

Bom dia Leandro, tudo bem ?

Conseguiu resolver o problema ? Estou com o mesmo problema.

Bom dia Hermes, tudo bem?

Ainda está com problema.

Eu abri um chamado, estou aguardando resposta.

Abraços.

@Leandro Macedo​

Bom dia Leandro,

Onde você envia o valor do vale no body?

Bom dia galera,

Estou com o mesmo problema em um cliente meu, como eu devo proceder @Nathan Prestes​ .

Lucas, sem um exemplo do que está enviando no POST fica difícil ajudar

@Nathan Prestes​

É para já segue meus casos.

1º tentativa de criação vinculada a um "CustomerID"

URL: https://{minhaloja}.vtexcommercestable.com.br/api/gift-card-system/pvt/giftCards

Header: x-vtex-api-appKey: {minhakey}

x-vtex-api-appToken: {meutoken}

Accept: application/json

Content-Type: application/json

Body:

{

"customerId": "20faf8e9-e118-11e8-823b-0a7843eb5f18",

"cardName": "TESTEP",

"expiringDate": "2019-02-02T00:00:00"

}

Retorno:

{ "error": { "code": "1", "message": "Object reference not set to an instance of an object.", "exception": { "ClassName": "Vtex.Practices.ServiceModel.Client.Exceptions.InternalServerErrorException", "Message": "Object reference not set to an instance of an object.", "Data": null, "InnerException": { "ClassName": "System.NullReferenceException", "Message": "Object reference not set to an instance of an object.", "Data": null, "InnerException": null, "HelpURL": null, "StackTraceString": " at Vtex.Commerce.GiftCardSystem.GiftCardCoordinator.<CreateGiftCard>d__7.MoveNext() in F:\\pachamama\\BuildAgent\\work\\5d610b39a5b8c096\\src\\Private Assemblies\\Vtex.Commerce.GiftCardSystem\\GiftCardCoordinator.cs:line 393\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Vtex.Commerce.GiftCardSystem.GiftCardApiController.<CreateGiftCard>d__3.MoveNext() in F:\\pachamama\\BuildAgent\\work\\5d610b39a5b8c096\\src\\Private Assemblies\\Vtex.Commerce.GiftCardSystem.WebApi\\GiftCardApiController.cs:line 96\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Vtex.Commerce.GiftCardSystem.ResourceFilter.<ExecuteAuthorizationFilterAsync>d__2.MoveNext() in F:\\pachamama\\BuildAgent\\work\\5d610b39a5b8c096\\src\\Private Assemblies\\Vtex.Commerce.GiftCardSystem.WebApi\\ResourceFilter.cs:line 40\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": "8\nMoveNext\nVtex.Commerce.GiftCardSystem, Version=1.3.48.161, Culture=neutral, PublicKeyToken=null\nVtex.Commerce.GiftCardSystem.GiftCardCoordinator+<CreateGiftCard>d__7\nVoid MoveNext()", "HResult": -2147467261, "Source": "Vtex.Commerce.GiftCardSystem", "WatsonBuckets": null }, "HelpURL": null, "StackTraceString": null, "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": null, "HResult": -2146233088, "Source": null, "WatsonBuckets": null } } }

2º tentativa

Criação de um giftcard simples sem nenhuma informação de cliente atrelada.

URL: https://api.vtexcommerce.com.br/{Minhaloja}/giftcards

Header: x-vtex-api-appKey: {minhakey}

x-vtex-api-appToken: {meutoken}

Accept:application/vnd.vtex.giftcardproviders.v1+json

Content-Type:application/vnd.vtex.giftcardproviders.v1+json

Body:

{

"relationName": "teste",

"expiringDate": "2020-01-01T00:00:00",

"caption": "TESTE",

"redemptionCode": "BAHD-ASDB-ADQW-ASDQ"

}

Retorno:

Server Error in '/AdminWebService' Application

Grato por sua ajuda e atenção

Você passou o valor no body conforme o Alan indicou? Imagino que essa seja a causa... mas é só um palpite.

Eu já apanhei muito para criar um vale via api, não me recordo o que tive que fazer sinceramente.

@Lucas Oliveira​

São três passos para criação do gift.

1) Buscar o CustomerID que é encontrado na API do OMS no campo UserProfileID

URL: http://sualoja.vtexcommercestable.com.br/api/oms/pvt/orders/v376822dmyl-01

"id": "clientProfileData", "email": "111@uol.com.br-16b.ct.vtex.com.br", "firstName": "11111", "lastName": "1111", "documentType": "cpf", "document": "11111111111", "phone": "+11111111", "corporateName": null, "tradeName": null, "corporateDocument": null, "stateInscription": null, "corporatePhone": null, "isCorporate": false, "userProfileId": "b12abc1e-ab36-41f0-9e23-83ee586745d5", "customerClass": null },

2) Criar o Gift atribuindo o UserProfileID no CUSTOMERID da API abaixo

URL:

http://SUALOJA.vtexcommercestable.com.br/api/gift-card-system/pvt/giftCards?customerId=b12abc1e-ab36-41f0-9e23-83ee586745d5

{ "customerId": "b6083944-1dc5-4169-b485-c6c6233b8ab9", "ownerId": "12356", "balance": "1", "cardName": "1536390", "caption": "TESTE ALAN 20/09", "expiringDate": "2018-11-06 00:00:00", "multipleCredits": true, "multipleRedemptions": true, "restrictedToOwner": true }

3) Atribuir valor ao Gift

URL: http://sualoja.vtexcommercestable.com.br/api/gift-card-system/pvt/giftCards/2020(id do gift retornado no momento da criação do mesmo na api anterior)/credit

{ "value": "10000" }

Qualquer dúvida me avise.

@Alan Abatti​

Muito obrigado, Salvouuuuuu!!!

Eu estava tentando utilizar o ID que eu buscava no MasterData

https://{minhaloja}.vtexcommercestable.com.br/api/dataentities/CL/search?_fields=document,email,id,firstName

só que agora eu tenho uma dúvida, se um cliente nunca fez um pedido, como eu poderia gerar ou buscar esse "userProfileId"?

hmmmmmmmm sabia que tinha essa pegadinha :)))))

Faz muito tempo que havia visto isso, perdi umas boas horas para descobrir na época.

Consegui criar vale da seguinte forma. Vi alguns post que explica como fazer, porem necessita de ter um pedido criado pelo cliente no oms.

anexo segue um tutorial, instruindo a criar GiftCard, de clientes que nunca compraram no ecommerce.

1) criar cliente no master data

2) Realizar a chamada para pegar o userId do perfil oms

3) Cria no método POST o Vale com o user id, para atribuir o CPF

4) Acessar a chamada para inserir o credito a partir do id criado na VTEX.