Behat is stop because there is an exception - api-platform.com

i have problem. My api-platfrom works ok, this return status code 409.
{
"type": "https:\/\/tools.ietf.org\/html\/rfc2616#section-10",
"title": "An error occurred",
"detail": "nip: This value is already used.",
"trace": [...]
}
...but my behat tests is not works. They stop because there is an exception.
Scenario: Write a new legal entity with nip is exists in database
Given I am logged as user 1
When I add "Content-Type" header equal to "application/json"
When I add "Accept" header equal to "application/json"
#this return response status code 409, but api platform throw exception
And I send a "POST" request to "/legal-entities"
"""json
{
"name": "Andrzej",
"nip": "3784696345",
"email": "fake1#email.com",
"url": null,
"addressLine1": "Andrzejów",
"addressLine2": "2",
"postcode": "00-000",
"province": "Lubelskie",
"city": "Andrzejowo",
"countryIso2": "PL"
}
"""
Then the response status code should be 409
i got failed tests https://i.stack.imgur.com/UaL6P.png
how fix them?

Related

YouTube API subscription insert always returns an error

How to Add a subscription for the authenticated user's channel
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&key={YOUR_API_KEY}
Request Parameters :-
{
"0":
{ "name": " <code>snippet.resourceId.kind</code>", "value": "youtube#channel" },
"1": { "name": " <code>snippet.resourceId.channelId</code>", "value": "UC_x5XG1OV2P6uZZ5FSM9Ttw" }
}
Response Parameters :-
{
"error":
{ "errors":
[ { "domain": "youtube.subscription", "reason": "publisherRequired", "message": "The subscription resource specified in the request must use the <code>snippet.resourceId</code> property to identify the channel that is being subscribed to." } ], "code": 400, "message": "The subscription resource specified in the request must use the <code>snippet.resourceId</code> property to identify the channel that is being subscribed to." }
}
This apears to be a bug in the Youtube api. this can be verifyed by checking the api explorer here .
POST https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&key={YOUR_API_KEY}
{
"0": {
"name": "snippet.resourceId",
"value": "youtube#channel"
},
"1": {
"name": "snippet.resourceId",
"value": "UC_x5XG1OV2P6uZZ5FSM9Ttw"
}
}
Response
{
"error": {
"errors": [
{
"domain": "youtube.subscription",
"reason": "publisherRequired",
"message": "The subscription resource specified in the request must use the <code>snippet.resourceId</code> property to identify the channel that is being subscribed to."
}
],
"code": 400,
"message": "The subscription resource specified in the request must use the <code>snippet.resourceId</code> property to identify the channel that is being subscribed to."
}
}
There is an issue request for this issue and the team has been pinged.
Link of Youtube Data API (V3), you can try here
it's the image example in "try this API" of how i do
POST https://www.googleapis.com/youtube/v3/subscriptions?part=snippet HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
{
"snippet": {
"resourceId": {
"kind": "youtube#channel",
"channelId": "UCUK0HBIBWgM2c4vsPhkYY4w"
}
}
}

Unable to hit url by HttpPOST in actionable cards in microsoft teams

I am trying to make a Actionable Message for Microsoft Teams with an ActionCard.
I want to hit a url by HttpPost. When I hit the url, I got the error message:
Failed to send
There was a problem submitting your changes. Try again in a minute.
I followed Microsoft's documentation and according to the documentation my code is right. I am very confuse why this error is coming up.
This is the ActionCard I'm using:
{
"#type": "ActionCard",
"name": "Selector",
"inputs": [{
"#type": "MultichoiceInput",
"id": "list",
"title": "Select a status",
"isMultiSelect": "false",
"style": "expanded",
"choices": [{
"display": "In Progress",
"value": "1"
},
{
"display": "Active",
"value": "2"
},
{
"display": "Closed",
"value": "3"
}
]
}],
"actions": [{
"#type": "HttpPOST",
"name": "Save",
"body": "value={{list.value}}",
"target": "https://www.google.com"
}]
}
Microsoft Teams is surfacing an error because you're call resulted in an error.
Your code looks fine but your target URL (Google.com) isn't valid. You can't make an POST request to https://www.google.com. Attempting to do so results in a Error 405 (Method Not Allowed).
Making an HttpPOST requires a target that is willing to accept it and return some type of 2xx Success response. Typically it will be 200 OK but some APIs get more granular with their responses (201 Created, 202 Accepted, etc.).

Skype/MS Team REST API not working

I'm creating a bot using REST API. Indeed, I want to send a message from my bot to me as following
I start with 'Authentification'
Request:
curl -k -X POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token -d "grant_type=client_credentials&client_id={app_id}&client_secret={app_password}&scope=https://graph.microsoft.com/.default"
Response:
{
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 0,
"access_token": "<access_token>"
}
Next, I start a new conversation
Request:
POST https://skype.botframework.com/v3/conversations
Authorization: Bearer <access_token>
Content-Type: application/json
{
"bot": {
"id": "standupalice",
"name": "Standup Alice"
},
"isGroup": false,
"members": [
{
"id": "<my bot id>",
"name": "Standup Alice"
},
{
"id": "<my user id>",
"name": "Bao"
}
],
"topicName": "News Alert"
}
NOTE: and are obtained from a callback message sent from Skype app to Standup Alice bot.
Response:
{
"id": "<conversation id>"
}
It's weird since the conversation ID is identical to . Well, now I compose a message to send to me as following
Request:
POST https://skype.botframework.com/v3/conversations/<conversation id>/activities
Authorization: Bearer <access_token>
Content-Type: application/json
{
"type": "message",
"from": {
"id": "<my bot id>",
"name": "Standup Alice"
},
"conversation": {
"id": "<conversation id>",
"name": "News Alert"
},
"recipient": {
"id": "<my user id>",
"name": "Bao"
},
"channelId": "skype",
"text": "My bot's reply"
}
Response (http error 400 - bad request):
{
"error": {
"code": "ServiceError",
"message": "The conversationId <conversation id>and bot <my bot id> doesn't match a known conversation"
}
}
Do you have an idea what's wrong with my requests and parameters?
Note 1: I tried to fire request to https://api.botframework.com/v3/conversations as described in https://docs.botframework.com/en-us/core-concepts/overview/#navtitle, but always receives http error 404 - Resource not found.
Note 2: I just tried the same way for webchat and it works fine, but MS Teams doesn't work (http error 500 - Internal Server Error)
Note 3: my channel settings
Your second API request (the one starting a conversation) should have returned something looking like this:
{
"activityId": "string",
"serviceUrl": "string",
"id": "string"
}
The fact that it didn't suggests to me that that's where the problem is (although full disclosure, I wasn't able to re-create it).
Looking at your "members" array, I see you added the bot. I'm not sure, strictly speaking, that a bot is a member (I think members are human, but I can't find a good definition). So, my best suggestion would be to remove the bot from the members array in that second API call.
Good luck!

botframework channelData for kik results in error: 400 (Bad Request)

I'm using the Microsoft Botframework and the node.js version of botbuilder. My bot can send messages to kik (and other services) using the shared message fields - the ones that the botconnector allows for all messages.
However, when I try to use channelData fields for kik, I get a 400 (Bad Request) error message. I have already adapted my message to use the tip from:
Bot Connector: Sending custom message to Kik results in 400 error
but I'm still missing something.
Thanks for any help on mapping the message properly for kik.
Code that results in the 400 error:
session.send({
type: "Message",
to: { "channelId":"kik", "address": session.message.from.address},
from: { "channelId":"kik", "address": session.message.to.address},
replyToMessageId: session.message.id,
conversationId: session.message.conversationId,
channelConversationId: session.message.channelConversationId,
channelMessageId: session.message.channelMessageId,
channelData:
{
"messages": [
{
"chatId": session.message.channelConversationId,
"type": "text",
"to": session.message.from.name,
"text": "test text",
"noForward": true
}
]
}
});
I've also tried sending only the channelData portion, but that also results in the 400 error:
channelData:
{
"messages": [
{
"chatId": session.message.channelConversationId,
"type": "text",
"to": session.message.from.name,
"text": "test text",
"noForward": true
}
]
}
I believe your data is malformed. Kik expects text content as "body" not "text". Try:
"messages": [
{
"chatId": session.message.channelConversationId,
"type": "text",
"to": session.message.from.name,
"body": "test text",
"noForward": true
}

Mailchimp API v3 add merge field with checkboxes

I need to add checkboxes merge-field with choices to a list.
API key is valid, other requests work and I'm doing such request:
POST https://us12.api.mailchimp.com/3.0/lists/424242/merge-fields
Body: {"name": "provider_accounts", "type": "checkboxes", "options": { "choices": ["BMW", "Audi", "Toyota"]}, "tag": "provider_accounts"}
And I got an error for some reason!
{
"type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title": "Invalid Resource",
"status": 400,
"detail": "The resource submitted could not be validated. For field-specific details, see the 'errors' array.",
"instance": "",
"errors": [
{},
{}
]
}
BTW if I change the type to radio request works and new merge-field is created.

Resources